Repository navigation
JSPWIKI-922 Encode non-ASCII attachment names in the Content-Disposition header - #571
Merged
arturobernalg merged 2 commits intoNov 2, 2026
Conversation
…ion header The name of an attachment was written as it is inside the quoted filename parameter. A character outside printable ASCII went out as a single raw byte (0xE4 for a-umlaut), which is not valid UTF-8, and a name with a quote or a backslash ended the quoted string. Such names now get an ASCII fallback in filename and the UTF-8 name, percent encoded, in filename* as in RFC 6266 and RFC 8187. Names made of printable ASCII characters are written as before.
udittmer
reviewed
Nov 2, 2026
Contributor
There was a problem hiding this comment.
I can confirm that this patch allows me to upload and download attachments with names containing umlauts, and that, after download, they're stored with their names intact. So it looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSPWIKI-922
AttachmentServlet wrote the name of an attachment as it is inside the quoted filename parameter of Content-Disposition. On a running instance (Tomcat 10.1, current master) an attachment named Täst.txt was served with
Content-Disposition: inline; filename="T\xE4st.txt";, that is one raw 0xE4 byte, which is not valid UTF-8. The header was the same over HTTP/1.1 and over HTTP/2. A name that contains a quote or a backslash also ended the quoted string.A name with a character outside printable ASCII, a quote or a backslash now gets an ASCII fallback in filename and the UTF-8 name, percent encoded, in filename* (RFC 6266, RFC 8187):
filename="T_st.txt"; filename*=UTF-8''T%C3%A4st.txt;. Names made of printable ASCII characters are written as before.Tests: 8 new tests in AttachmentServletTest. They do not compile on master, because encodeFileName does not exist there. AttachmentServletTest (10 tests), AttachmentManagerTest (14) and BasicAttachmentProviderTest (13) pass. On a running instance with this change, an attachment with an umlaut, one with a Chinese name and one with a quote in the name were downloaded with status 200 over HTTP/1.1 and over HTTP/2 without TLS, with the new header.
Not tested: Firefox and HTTP/2 over TLS. A comment on JSPWIKI-922 reports a network error when a file with umlauts in its name is downloaded in Firefox; it is not known whether this change affects that error.