in_http: Fast fix for the issue related to validate the Content-Type
Fix to accept a Content Type Header that have application/json and other configurations, ex: charset
Fixes https://github.com/fluent/fluent-bit/issues/5062 Enter [N/A] in the box, if an item is not applicable to your change.
Testing Before we can approve your change; please submit the following in a comment:
[N/A] Example configuration file for the change [ N/A] Debug log output from testing the change [ N/A] Attached Valgrind output that shows no leaks or memory corruption was found If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
[N/A] Attached local packaging test output showing all targets (including any new ones) build. Documentation
[N/A] Documentation required for this feature Backporting
[N/A] Backport to latest stable release.
I updated my repository with the latest changes from master and created a new pull request with the proposed change. This is the old pr: https://github.com/fluent/fluent-bit/pull/5272.
I also added the signed off comments.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
The only issue I have with this is that according to RFC 7231 if there are any parameters they should be separated from the media type by a semicolon and with your patch any trailing characters would still match (ie. application/json_but_a_non_compliant_one_actually).
So I think the uglier but more compliant version would be :
if (header->val.len > 16 &&
strncasecmp(header->val.data, "application/json;", 17) == 0) {
type = HTTP_CONTENT_JSON;
}
else if (header->val.len == 16 &&
strncasecmp(header->val.data, "application/json", 16) == 0) {
type = HTTP_CONTENT_JSON;
}
I couldn't find anything in the RFC about spaces before the semicolon so I assume this simplistic ugly approach would cover the majority of cases but honestly, I don't even know if it's worth the hassle trying to ensure that there are no trailing characters that break the comparison...
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
Hi, I will add these changes.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.