synchronoss / nio-multipart

A multipart library that uses nio and asynchronous processing
Apache License 2.0
93 stars 20 forks source link

Do not use default charset for decoding headers (bad practice) #9

Open defnull opened 6 years ago

defnull commented 6 years ago

Headers are currently decoded using the system default charset if no explicit charset is passed to the MultipartContext. This caused my application to work correctly on my laptop and the integration test server, but broke in production because the docker container defaulted to latin-1 instead of utf-8 :(

Using the system default charset for anything but console output is considered bad practice as it breaks portability. There is even a JEP draft to deprecate the default charset. See http://openjdk.java.net/jeps/8187041

MultipartContext should not allow null as a charEncoding parameter, or default to UTF-8 (all modern browsers and most HTTP client libraries use UTF-8 per default, even if the RFCs are unclear about this).