Skip to content

Fall back to the default charset when the multipart charset is not supported - #1677

Open
17krishna8 wants to merge 1 commit into
apache:masterfrom
17krishna8:multipart-charset-name-invalid
Open

17krishna8 wants to merge 1 commit into
apache:masterfrom
17krishna8:multipart-charset-name-invalid

Conversation

@17krishna8

Copy link
Copy Markdown

Follow-up to #1675, which made RequestUtils.getCharset() fall back to the default for a charset name that is not legal.

MultipartServletWebRequestImpl.parseFileParts() reads the character encoding of the request and hands it to Charset.forName() twice, once for the file upload and once for decoding the form field values. commons-fileupload2 also resolves the charset of the request context eagerly while it parses the parts. For a charset the platform does not know, e.g. a made-up name sent as the charset parameter of the Content-Type header, Charset.forName() throws and the parsing of the parts fails.

Fall back to the same default a missing encoding already uses, the response request encoding of the application, and answer that encoding from the request context, so that the parts are still parsed.

…pported

MultipartServletWebRequestImpl.parseFileParts() reads the character
encoding of the request and hands it to Charset.forName() twice, once
for the file upload and once for decoding the form field values.
commons-fileupload2 also resolves the charset of the request context
eagerly while it parses the parts. For a charset the platform does not
know, e.g. a made-up name sent as the charset parameter of the
Content-Type header, Charset.forName() throws and the parsing of the
parts fails.

Fall back to the same default a missing encoding already uses, the
response request encoding of the application, and answer that encoding
from the request context, so that the parts are still parsed.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.96%. Comparing base (9395042) to head (aa7672e).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1677   +/-   ##
=========================================
  Coverage     61.96%   61.96%           
- Complexity    11286    11288    +2     
=========================================
  Files          1250     1250           
  Lines         48437    48444    +7     
  Branches       6796     6796           
=========================================
+ Hits          30014    30020    +6     
- Misses        15729    15731    +2     
+ Partials       2694     2693    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants