Bug 594730 - Make the content attribute in <meta> act as an encoding declaration only if http-equiv="Content-Type" is present. rs=jonas, a=blocking2.0-betaN.

This commit is contained in:
Henri Sivonen
2010-12-08 14:37:19 +02:00
parent 84cb7c5086
commit e4808f1f2e
22 changed files with 471 additions and 203 deletions

View File

@@ -2024,21 +2024,26 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue)
void
nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes)
{
nsString* content = attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT);
nsString* internalCharsetLegacy = nsnull;
if (content) {
internalCharsetLegacy = nsHtml5TreeBuilder::extractCharsetFromContent(content);
}
if (!internalCharsetLegacy) {
nsString* internalCharsetHtml5 = attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET);
if (internalCharsetHtml5) {
tokenizer->internalEncodingDeclaration(internalCharsetHtml5);
nsString* charset = attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET);
if (charset) {
if (tokenizer->internalEncodingDeclaration(charset)) {
requestSuspension();
return;
}
} else {
tokenizer->internalEncodingDeclaration(internalCharsetLegacy);
nsHtml5Portability::releaseString(internalCharsetLegacy);
requestSuspension();
return;
}
if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("content-type", attributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) {
return;
}
nsString* content = attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT);
if (content) {
nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content);
if (extract) {
if (tokenizer->internalEncodingDeclaration(extract)) {
requestSuspension();
}
}
nsHtml5Portability::releaseString(extract);
}
}