filenames in multipart/form-data are not percent decoded
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
For the following form:
<pre>
<?php
var_dump(PHP_VERSION);
var_dump($_FILES);
?>
</pre>
<form method="post" action="test.php" enctype="multipart/form-data">
<input type="file" name="some_file">
<button type="submit">Submit</button>
</form>
Uploading a file called ".txt in Firefox and Chrome
Resulted in this output:
string(5) "8.1.3"
array(1) {
["some_file"]=>
array(6) {
["name"]=>
string(7) "%22.txt"
["full_path"]=>
string(7) "%22.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(14) "/tmp/phpWl5h5S"
["error"]=>
int(0)
["size"]=>
int(0)
}
}
But I expected this output instead:
string(5) "8.1.3"
array(1) {
["some_file"]=>
array(6) {
["name"]=>
string(5) "".txt"
["full_path"]=>
string(5) "".txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(14) "/tmp/phpWl5h5S"
["error"]=>
int(0)
["size"]=>
int(0)
}
}
Because I wasn't sure about the correct behavior myself I've checked with #curl on irc.libera.chat. In the replies I got the following references:
- https://daniel.haxx.se/blog/2021/11/13/fun-multipart-form-data-inconsistencies/
- https://github.com/curl/curl/issues/7789
RFC 7578#2 specifies percent-encoding for use in HTTP
So nowadays special characters, specifically the double quote (") are percent-encoded instead of backslash-encoded and PHP should properly decode those, like it already does for backslash encoding.
PHP Version
8.1.3
Operating System
Docker on Ubuntu 20.04
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、PHP 8.1.3 で説明されている multipart/form-data アップロードを、ダブルクォートを含むファイル名を使って再現し、結果として得られる $_FILES の name と full_path の値を調べます。パーセントエンコードの処理を、既存のバックスラッシュエンコードの挙動と比較します。完了条件は、両方のフィールドにデコードされたファイル名が含まれていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100