Bug 1282486 - Plugin fallback rule - don't use fallback when it contains 'install Flash' instructions
MozReview-Commit-ID: 5e9tgoU1vob
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -3628,31 +3628,49 @@ nsObjectLoadingContent::HasGoodFallback(
// RULE "adobelink":
// Don't use fallback content when it has a link to adobe's website.
if (rulesList[i].EqualsLiteral("adobelink")) {
nsTArray<nsINodeList*> childNodes;
for (nsIContent* child = thisContent->GetFirstChild();
child;
child = child->GetNextNode(thisContent)) {
if (child->IsHTMLElement(nsGkAtoms::a)) {
- nsCOMPtr<nsIURI> href = child->GetHerfURI();
+ nsCOMPtr<nsIURI> href = child->GetHrefURI();
if (href) {
nsAutoCString asciiHost;
nsresult rv = href->GetAsciiHost(asciiHost);
- if (!asciiHost.IsEmpty() &&
+ if (NS_SUCCEEDED(rv) &&
+ !asciiHost.IsEmpty() &&
(asciiHost.EqualsLiteral("adobe.com") ||
- asciiHost.EqualsLiteral("www.adobe.com") ||
- asciiHost.EqualsLiteral("get.adobe.com"))) {
+ StringEndsWith(asciiHost, NS_LITERAL_CSTRING(".adobe.com")))) {
return false;
}
}
}
}
}
+ // RULE "installinstructions":
+ // Don't use fallback content when the text content on the fallback appears
+ // to contain instructions to install or download Flash.
+ if (rulesList[i].EqualsLiteral("installinstructions")) {
+ nsAutoString textContent;
+ ErrorResult rv;
+ thisContent->GetTextContent(textContent, rv);
+ bool hasText =
+ !rv.Failed() &&
+ (CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Flash"), textContent) ||
+ CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Install"), textContent) ||
+ CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Download"), textContent));
+
+ if (hasText) {
+ return false;
+ }
+ }
+
// RULE "true":
// By having a rule that returns true, we can put it at the end of the rules list
// to change the default-to-false behavior to be default-to-true.
if (rulesList[i].EqualsLiteral("true")) {
return true;
}
}