Bug 1372994 addendum - Sanitize encoding names from old cache entries. r=emk

MozReview-Commit-ID: GcMlVEfaPnD

--HG--
extra : rebase_source : f67aff5985be1f2f472dccb400773abaffea40e0
This commit is contained in:
Henri Sivonen 2017-06-15 10:52:31 +03:00
Родитель 2f2bb984f8
Коммит 3822db8d6c
1 изменённых файлов: 10 добавлений и 3 удалений

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

@ -357,12 +357,19 @@ nsHTMLDocument::TryCacheCharset(nsICachingChannel* aCachingChannel,
nsCString cachedCharset;
rv = aCachingChannel->GetCacheTokenCachedCharset(cachedCharset);
if (NS_FAILED(rv) || cachedCharset.IsEmpty()) {
return;
}
// The canonical names changed, so the cache may have an old name.
if (!cachedCharset.EqualsLiteral("replacement")) {
if (!EncodingUtils::FindEncodingForLabel(cachedCharset, cachedCharset)) {
return;
}
}
// Check EncodingUtils::IsAsciiCompatible() even in the cache case, because the value
// might be stale and in the case of a stale charset that is not a rough
// ASCII superset, the parser has no way to recover.
if (NS_SUCCEEDED(rv) &&
!cachedCharset.IsEmpty() &&
EncodingUtils::IsAsciiCompatible(cachedCharset))
if (EncodingUtils::IsAsciiCompatible(cachedCharset))
{
aCharset = cachedCharset;
aCharsetSource = kCharsetFromCache;