-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header content-type not enforcing charset #26610
Comments
The First question is whether we still need some sort of improvement to the logic introduced in 5.2.7 and 5.2.8. Maybe the charset should be checked after all and for example UTF-16 filtered out in Second, that is still not the same as the having the |
In addition to what @rstoyanchev wrote, I am finding it difficult to reproduce the The only way I can reproduce the issue is by sending plain ASCII/UTF-8 data, and pretending it's UTF-16 in the Content-Type. For instance by using a curl command like:
However, I would say that this is expected behavior. If you'd like us to spend some more time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
@poutsma @rstoyanchev I'll try to find some free time in the next day or two to create a demo project reproducing this behavior. |
@sada-sigsci the quick summary is that what you saw in 5.2.7 was temporary behavior. The current (and correct) behavior as of 5.2.8 is that there shouldn't be a 415. Reading should just work as long as the charset is valid and supported. If you get a parse error, most likely it means the content submitted by the client wasn't encoded according to the charset specified in the media type. Related to that there is now an improvement with #26627 to rely on Jackson to auto-detect the charset even if the one on the media type doesn't match. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Hi,
after upgrading from Spring boot 2.3.1.RELEASE to 2.4.2 it seems the value for the
content-type
header isn't fully validated.openjdk version "11.0.9.1" 2020-11-04
Kotlin version 1.4.30
Example:
Behavior on Spring 2.3.1-RELEASE:
Request with header
Content-Type : application/vnd.api+json;charset=utf-8
is allowed ✅Request with header
Content-Type : application/vnd.api+json;charset=utf-16
rejected with415
status ✅Request with header
Content-Type : application/vnd.api+json;charset=test
rejected with415
status ✅Behavior on Spring 2.4.2:
Request with header
Content-Type : application/vnd.api+json;charset=utf-8
is allowed ✅Request with header
Content-Type : application/vnd.api+json;charset=utf-16
isn't rejected with415
status and results in an expcetion being thrown ❌Request with header
Content-Type : application/vnd.api+json;charset=test
rejected with415
status ✅Additionall info:
Request with header
Content-Type : application/vnd.api+json
(without specifying the charset) get's allowed (I'm assuming it's defaulting toutf-8
) with both versions. I would expect the request to be rejected in this case.The text was updated successfully, but these errors were encountered: