(fixed #3966) ファイルダウンロード時の日本語ファイル名文字化け修正#370
Open
nishizoe wants to merge 4 commits intoopenpne:old-masterfrom
Open
(fixed #3966) ファイルダウンロード時の日本語ファイル名文字化け修正#370nishizoe wants to merge 4 commits intoopenpne:old-masterfrom
nishizoe wants to merge 4 commits intoopenpne:old-masterfrom
Conversation
…... にURL エンコードされた UTF-8 のファイル名 を設定するよう修正
upsilon
requested changes
Oct 5, 2016
| $original_filename = str_replace(array("\r", "\n"), '', $original_filename); | ||
| $filename = str_replace(array("\r", "\n"), '', $filename); | ||
|
|
||
| $encoded_filename = rawurlencode($original_filename); |
Member
There was a problem hiding this comment.
$encoded_filename について、ファイル名に含まれる改行文字が除去されていません。header 関数に渡す文字列に改行文字を許容すると HTTP ヘッダインジェクションが可能になる場合があるため、$filename と $encoded_filename の両方とも改行文字が含まれないように修正して下さい。
参考: http://blog.tokumaru.org/2015/12/phphttp.html
upsilon
approved these changes
Oct 5, 2016
upsilon
requested changes
Oct 7, 2016
Member
upsilon
left a comment
There was a problem hiding this comment.
IE8 での挙動について、filename に URL エンコードされた UTF-8 の文字列を渡すことでマルチバイト文字を含むファイル名でも文字化けせずに表示されることを確認したため、Content-Disposition ヘッダについてはリクエストの User-Agent に関わらず常に下記のようなヘッダを返すように修正して下さい。
Content-Disposition: attachment; filename="%E6%97%A5%E6%9C%AC%E8%AA%9E.txt"; filename*=utf-8''%E6%97%A5%E6%9C%AC%E8%AA%9E.txt
upsilon
approved these changes
Oct 7, 2016
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.
チケット: https://redmine.openpne.jp/issues/3966