Bug 490916 - Trim space characters from encoding names in the HTML5 parser. r=jonas, a=jst.

This commit is contained in:
Henri Sivonen 2011-01-12 10:05:09 +02:00
Родитель 85ad492c0a
Коммит ae4be142ed
6 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -69,6 +69,7 @@ nsHtml5MetaScanner::tryCharset(nsString* charset)
}
nsCAutoString encoding;
CopyUTF16toUTF8(*charset, encoding);
encoding.Trim(" \t\r\n\f");
if (encoding.LowerCaseEqualsLiteral("utf-16") ||
encoding.LowerCaseEqualsLiteral("utf-16be") ||
encoding.LowerCaseEqualsLiteral("utf-16le")) {

Просмотреть файл

@ -144,8 +144,11 @@ nsHtml5Parser::SetDocumentCharset(const nsACString& aCharset,
NS_PRECONDITION(!mExecutor->HasStarted(),
"Document charset set too late.");
NS_PRECONDITION(mStreamParser, "Setting charset on a script-only parser.");
mStreamParser->SetDocumentCharset(aCharset, aCharsetSource);
mExecutor->SetDocumentCharsetAndSource((nsACString&)aCharset,
nsCAutoString trimmed;
trimmed.Assign(aCharset);
trimmed.Trim(" \t\r\n\f");
mStreamParser->SetDocumentCharset(trimmed, aCharsetSource);
mExecutor->SetDocumentCharsetAndSource(trimmed,
aCharsetSource);
}

Просмотреть файл

@ -768,7 +768,7 @@ nsHtml5StreamParser::internalEncodingDeclaration(nsString* aEncoding)
nsCAutoString newEncoding;
CopyUTF16toUTF8(*aEncoding, newEncoding);
// XXX spec says only UTF-16
newEncoding.Trim(" \t\r\n\f");
if (newEncoding.LowerCaseEqualsLiteral("utf-16") ||
newEncoding.LowerCaseEqualsLiteral("utf-16be") ||
newEncoding.LowerCaseEqualsLiteral("utf-16le")) {

Просмотреть файл

@ -81,6 +81,7 @@ _TEST_FILES = parser_datreader.js \
file_bug594730-6.html \
file_bug594730-7.html \
file_bug594730-8.html \
file_bug594730-9.html \
test_bug599584.html \
iframe_bug599584.html \
$(NULL)

Просмотреть файл

@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="
Windows-1250
">
<script>parent.is("ø", "\u0159", "Decoded bytes should have matched the Unicode escape.");</script>

Просмотреть файл

@ -22,6 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=594730
<iframe src=file_bug594730-6.html></iframe>
<iframe src=file_bug594730-7.html></iframe>
<iframe src=file_bug594730-8.html></iframe>
<iframe src=file_bug594730-9.html></iframe>
<pre id="test">
<script class="testbody" type="text/javascript">
</script>