url
url copied to clipboard
Characters in a query aren't replaced with character references / クエリの文字が文字参照に置き換えられない
- PHP 5.6.10
- libmbfl 1.3.2
- iconv 2.17
- esperecyan/url 1.0.2
If a input passed to lib\URLencoding::serializeURLencoded() or lib\URL::parseBasicURL() includes characters not encoded using $encodingOverride, the charcters will be replaced with such as percent-encoded "?" (on the specification, must be replaced percent-encoded character references.) For this reason, the tests, lib\URLtest::testParseBasicURL with data set #10 and lib\URLencodingTest::testSerializeURLencoded with data set #5, fail, and structural elements depending the methods influence. This cause is lib\URLencoding class implements encode internally using mb_convert_encoding() and iconv(), and the functions don't implement the error handling like HTML error mode.
A possible solution would be to create a library implementing Encoding Standard according to the specification, and use it in the methods.
lib\URLencoding::serializeURLencoded()、またはlib\URL::parseBasicURL()の入力に $encodingOverride で符号化できない文字が含まれていた場合、「?」などのパーセント符号化に置き換えられてしまいます (仕様上は、文字参照のパーセント符号化に置き換えられなければならない)。このため、lib\URLtest::testParseBasicURL with data set #10、lib\URLencodingTest::testSerializeURLencoded with data set #5のテストが失敗し、これらのメソッドに依存している構造要素も影響を受けます。lib\URLencoding クラスは符号化を、mb_convert_encoding()とiconv()を利用して内部用に実装していますが、 HTML エラーモードのようなエラー処理がそれらの関数に実装されていないことが原因です。
Encoding Standardを仕様通りに実装するライブラリを作成し、これらのメソッドの中で利用することが解決方法として考えられます。