-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Allow configuring the message converter in HttpPutFormContentFilter [SPR-14503] #19072
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
Comments
Rossen Stoyanchev commented Sorry but I'm not following what you mean. How exactly is the filename getting set given that InputStreamResourse does not have a filename? |
Serhii Hromovyi commented It's just plain http multipart request. |
Rossen Stoyanchev commented Sorry but the use case is still not clear. The original description mentions |
Vyacheslav Artemyev commented
byte[] headerName = getAsciiBytes(entry.getKey()); Why? |
Rossen Stoyanchev commented Vyacheslav Artemyev, to answer the why question first, MIME header fields are restricted to US-ASCII characters. From the multipart form-data spec RFC 7578:
Now how to actually do non-ASCII filenames? This is where the confusion begins. The old multipart form-data spec RFC 2388 (in section 4.4) recommends a type of encoding described in RFC 2231 and later specifically for header fields in RFC 5987 which explicitly puts the encoding in the header field, e.g. Now the latest RFC 7578 that I quoted in the beginning, in the same section notes not to use RFC 5987 style encoding (as we did for #16724) but to use percent encoding instead. It also adds a comment that "Some commonly deployed systems use multipart/form-data with file names directly encoded including octets outside the US-ASCII range." This is quite a mess. We could take the advice in the latest spec and use percent encoding but the other side would have to know to decode it likewise. Furthermore the I'm not sure what to make of the comment that some systems plainly ignore the US-ASCII restriction. If we did follow the spec recommendation to percent encode, that would conflict with systems that ignore the ASCII restriction. Oddly enough for an RFC, both of these -- percent encoding and forget ASCII restriction -- make it impossible for the receiving side to do the right thing unless it matched exactly what the sending side did. At this point I'm more inclined to stick to the existing Have you tried that property? Does it work for you? |
Paul commented Our detailed use case is following: But for me it looks like there is no real clients that area beware of this RFC. I think that the most popular client for multipart upload is js and it doesn't respect RFC. Also there may be clients that upload files percent-quoted out of the box, but then they decide filenames out of the box too. If utf-8 support for filenames will be enabled by default - neither first or second will suffer - things will continue to work for them executive as now. |
Vyacheslav Artemyev commented Rossen Stoyanchev, can you explain how can I use solution with FormHttpMessageConverter -> AllEncompassingFormHttpMessageConverter -> HttpPutFormContentFilter In this case I can't use |
Rossen Stoyanchev commented Indeed when used through the Regarding browsers HTML5 recommends to use the encoding of the form: "File names included in the generated multipart/form-data resource (as part of file fields) must use the character encoding selected above. Previously HTML 4 recommended encoding non-ascii filenames. So we need to review our present arrangement in light of all this. |
Vyacheslav Artemyev commented Rossen Stoyanchev, can you explain this phrase: I found that What do you think about it? If you agree with this approach, I can make new pull request with this solution. P.S. we aslo can add another property like: spring.mvc.formcontent.putfilter.multipartcharset in property file. |
Rossen Stoyanchev commented At the level of the |
Rossen Stoyanchev commented Modified title (was: "FormHttpMessageConverter.MultipartHttpOutputMessage writes headers in ASCII so Content-Disposition could not contain filename with non-ascii symbols"). |
Serhii Hromovyi opened SPR-14503 and commented
Hi,
we faced a problem using FormHttpMessageConverter.MultipartHttpOutputMessage while processing multipart request.
Our case is very similar to #16724, but with the only difference - we operate with InputStreamResourse (getFilename always returns null) and filename of multipart is defined in Content-Disposition header. And when MultipartHttpOutputMessage invokes writeHeaders() method - header value is retrieved in ASCII encoding:
byte[] headerValue = getAsciiBytes(headerValueString);
In our case we have there filename, which contains cyrillic symbols, that are transformed to "?" afterwards.
Is it ok, that ASCII encoding is using there?
If so - is it possible to allow us at least to override this encoding? Cause now there is no possibility to do it.
Affects: 4.2.6
Issue Links:
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: