diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt index 3209c3e5d6ae0..130447228f4d8 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt @@ -12,6 +12,10 @@ http_server_skipif(); require "./ext/standard/tests/http/server.inc"; $tests = [ + "No slashes" => [ + "foo", + " ", + ], "Invalid type/subtype" => [ "/html; Charset=\"ISO-8859-1\"", "text/; Charset=\"ISO-8859-1\"", @@ -32,6 +36,8 @@ $tests = [ "All valid inputs" => [ "text/html; charset=ISO-8859-1", "\t\r text/html; charset=ISO-8859-1 \t", + "\t\r text/html; charset=ISO-8859-1 \t;bar=\"foo\"", + "\t\r text/html; charset=ISO-8859-1 \t;bar=\"foo\"\r\n\t ", "text/html; foo=bar;charset=ISO-8859-1", "text/html; foo=bar;charset=ISO-8859-1;bar=\"foooooo\"", "text/html;;;; charset=ISO-8859-1", @@ -45,6 +51,7 @@ $tests = [ "text/html;Charset=\"ISO-8859-1\\", "text/html;Charset=\"ISO-8859-1\\\"", "text/html;Charset=\"foobar\\\"", + "text/html;Charset=\"%7F\\\"", "text/html;Charset=\"\\\"", "text/html;Charset=", ], @@ -62,6 +69,9 @@ foreach ($tests as $name => $headers) { } ?> --EXPECT-- +--- No slashes --- +��� +��� --- Invalid type/subtype --- ��� ��� @@ -88,9 +98,12 @@ foreach ($tests as $name => $headers) { äöü äöü äöü +äöü +äöü --- Valid input, but invalid encoding name --- ��� ��� ��� ��� ��� +��� diff --git a/ext/libxml/mime_sniff.c b/ext/libxml/mime_sniff.c index 5692f70ee251e..79ce1dc46b5e0 100644 --- a/ext/libxml/mime_sniff.c +++ b/ext/libxml/mime_sniff.c @@ -195,7 +195,7 @@ PHP_LIBXML_API zend_string *php_libxml_sniff_charset_from_string(const char *sta while (start < end && is_http_whitespace(*start)) { start++; } - while (start < end && is_http_whitespace(*end)) { + while (start < end && is_http_whitespace(*(end - 1))) { end--; }