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

Change '+' to spaces in file name during file download #237

Closed
GithubJohn3031 opened this Issue Apr 12, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@GithubJohn3031

GithubJohn3031 commented Apr 12, 2016

If filenames have spaces during download the spaces are changed to "+". So if file name is "my picture.jpg" Firefox loads a file as "my+picture.jpg". I've seen this issue only in Firefox, but possibly it occured also in another browsers.
I've found 2 places for file download in Omnifaces. The solution can be replacement of "+" to "%20". Tested with Ie8, Ie11, Firefox, Chrome

FacesLocal.sendFile:

        externalContext.setResponseHeader("Content-Disposition", String.format(SENDFILE_HEADER,
            (attachment ? "attachment" : "inline"), encodeURL(filename)));

to

        externalContext.setResponseHeader("Content-Disposition", String.format(SENDFILE_HEADER,
            (attachment ? "attachment" : "inline"), encodeURL(filename).replace("+", "%20")));

FileServlet.setContentHeaders

String filename = encodeURL(getAttachmentName(request, resource.file));
@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 19, 2016

Member

Fix is available in today's 2.4-SNAPSHOT.

Thank you for improving OmniFaces!

Member

BalusC commented Apr 19, 2016

Fix is available in today's 2.4-SNAPSHOT.

Thank you for improving OmniFaces!

@BalusC BalusC closed this Apr 19, 2016

BalusC added a commit that referenced this issue Apr 20, 2016

#237: clarify encodeURI javadoc and fix FileServlet filename as well
(it's unnecessary on ETag and for backwards compatibility I'd rather not
change it)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment