-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] automatically generate safe fallback filename #16656
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
Conversation
xabbuh
commented
Nov 24, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #16603 |
License | MIT |
Doc PR |
Hi Christian, Best regards, Yannik |
Why couldn't we use RFC 2231? |
@nicolas-grekas Encoding a string according to RFC 2231 leads to |
@xabbuh Your PR is awesome! Hopefully this will be merged into Symfony. |
@nicolas-grekas @xabbuh Can we find something that works for everyone here? I'd like to merge this one ASAP if possible. |
If we removed the limitation of not being able to have the percent character in the fallback filename, we could use RFC 2231 afaics as @nicolas-grekas proposed. But I am not sure why this check was added initially. |
@@ -157,6 +157,20 @@ public function setContentDisposition($disposition, $filename = '', $filenameFal | |||
$filename = $this->file->getFilename(); | |||
} | |||
|
|||
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { | |||
$encoding = mb_detect_encoding($filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mb_detect_encoding($string, null, true)
to enable strict mode (non-strict is useless)
@xabbuh Do you have time to finish this one? If not, just let me know and I will finish it for you. |
@fabpot @nicolas-grekas I pushed an update. |
👍 |
1 similar comment
👍 |
Thank you @xabbuh. |
…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
@fabpot Will this be merged into the more current releases of symfony? |
@Yannik Yes, we regularly merge lower branches into all higher maintained branches. |