-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
BinaryFileResponse attachment doesn't work with non-ascii filenames #16603
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
Labels
Comments
see #16656 |
Status: Reviewed |
This is RFC 2231 |
+1 👍 Had the issue today. |
fabpot
added a commit
that referenced
this issue
Mar 4, 2016
…name (xabbuh) This PR was merged into the 2.3 branch. Discussion ---------- [HttpFoundation] automatically generate safe fallback filename | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16603 | License | MIT | Doc PR | Commits ------- 03721e3 automatically generate safe fallback filename
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi everyone,
at the moment, it is impossible to create a BinaryFileResponse with a file which has a non-ascii filename:
This results in a
InvalidArgumentException
with message'The filename fallback must only contain ASCII characters.'
The stacktrace for the exception is:
However, it is not possible to instantiate a BinaryFileResponse and pass a filename fallback.
In fact, when
setContentDisposition
is called without a fallback filename (as is done bysetFile
), according to the DocBlock:the fallback filename should default to a automatically created ascii version.
However, this does not happen:
$filenameFallback
is just left to be a empty string.makeDisposition
then sets the fallback filename to the (possibly utf8) filename gotten thoughgetFilename()
:which then causes the exception.
Possible solutions:
setContentDisposition
act as it's docblock describes and set the fallback filename to an automatically encoded version of the filename if no other fallback filename is givensetContentDisposition
The text was updated successfully, but these errors were encountered: