diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index f1bbc962019..3130f64527b 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -539,6 +539,10 @@ pref("browser.safebrowsing.provider.0.reportPhishURL", "http://{moz:locale}.phis // FAQ URL pref("browser.safebrowsing.warning.infoURL", "http://%LOCALE%.www.mozilla.com/%LOCALE%/firefox/phishing-protection/"); + +// Name of the about: page contributed by safebrowsing to handle display of error +// pages on phishing/malware hits. (bug 399233) +pref("urlclassifier.alternate_error_page", "blocked"); #endif // defaults to true diff --git a/mozilla/browser/components/safebrowsing/content/application.js b/mozilla/browser/components/safebrowsing/content/application.js index bce52af2ba4..31c8460c17a 100644 --- a/mozilla/browser/components/safebrowsing/content/application.js +++ b/mozilla/browser/components/safebrowsing/content/application.js @@ -38,8 +38,8 @@ var gDataProvider = null; // An instance of our application is a PROT_Application object. It -// basically just populates a few globals and instantiates wardens and -// the listmanager. +// basically just populates a few globals and instantiates wardens, +// the listmanager, and the about:blocked error page. /** * An instance of our application. There should be exactly one of these. @@ -100,3 +100,30 @@ function PROT_Application() { PROT_Application.prototype.getReportURL = function(name) { return gDataProvider["getReport" + name + "URL"](); } + +/** + * about:blocked implementation + */ +PROT_Application.prototype.newChannel = function(uri) { + var ioService = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService); + var childURI = ioService.newURI("chrome://browser/content/safebrowsing/blockedSite.xhtml", + null, null); + var channel = ioService.newChannelFromURI(childURI); + channel.originalURI = uri; + + return channel; +} + +PROT_Application.prototype.getURIFlags = function(uri) { + return Ci.nsIAboutModule.ALLOW_SCRIPT; +} + +PROT_Application.prototype.QueryInterface = function(iid) { + if (iid.equals(Ci.nsISupports) || + iid.equals(Ci.nsIAboutModule)) + return this; + + Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE; + return null; +} diff --git a/mozilla/browser/components/safebrowsing/content/blockedSite.xhtml b/mozilla/browser/components/safebrowsing/content/blockedSite.xhtml new file mode 100644 index 00000000000..63a145e14c8 --- /dev/null +++ b/mozilla/browser/components/safebrowsing/content/blockedSite.xhtml @@ -0,0 +1,210 @@ + + + + %htmlDTD; + + %globalDTD; + + %brandDTD; + + %blockedSiteDTD; +]> + + + + +
+ + + + + + + + +Attack sites try to install programs that steal private information, use your computer to attack others, or damage your system.
\nWeb site owners who believe their site has been reported as an attack site in error may request a review.
+ +phishing.title=Suspected Web Forgery! +phishing.shortDesc=The web site at %S has been reported as a web forgery designed to trick users into sharing personal or financial information. +phishing.longDesc=Entering any personal information on this page may result in identity theft or other fraud.
These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.
+ +# Localization note (phishing.learnMoreLink): please leave the text +# as-is. A localized href is pulled in from user preferences automatically. +phishing.learnMoreLink=You can find out more about how %S protects you from phishing attacks.
diff --git a/mozilla/browser/locales/en-US/chrome/overrides/appstrings.properties b/mozilla/browser/locales/en-US/chrome/overrides/appstrings.properties index 357abe385ca..e70e7632de7 100644 --- a/mozilla/browser/locales/en-US/chrome/overrides/appstrings.properties +++ b/mozilla/browser/locales/en-US/chrome/overrides/appstrings.properties @@ -60,3 +60,4 @@ externalProtocolUnknown=Attack sites try to install programs that steal private information, use your computer to attack others, or damage your system.
Web site owners who believe their site has been reported as an attack site in error may request a review.
"> + + +Entering any personal information on this page may result in identity theft or other fraud. +These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.
+"> diff --git a/mozilla/browser/locales/jar.mn b/mozilla/browser/locales/jar.mn index 830120e52d1..686a5ba45a2 100644 --- a/mozilla/browser/locales/jar.mn +++ b/mozilla/browser/locales/jar.mn @@ -37,6 +37,7 @@ #ifdef MOZ_SAFE_BROWSING locale/browser/safebrowsing/phishing-afterload-warning-message.dtd (%chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd) locale/browser/safebrowsing/report-phishing.dtd (%chrome/browser/safebrowsing/report-phishing.dtd) + locale/browser/safebrowsing/blockedSite.properties (%chrome/browser/safebrowsing/blockedSite.properties) #endif locale/browser/feeds/subscribe.dtd (%chrome/browser/feeds/subscribe.dtd) locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties) diff --git a/mozilla/camino/embed-replacements/locale/en-US/global/netError.dtd b/mozilla/camino/embed-replacements/locale/en-US/global/netError.dtd index 13ae7d59441..406bde0de08 100644 --- a/mozilla/camino/embed-replacements/locale/en-US/global/netError.dtd +++ b/mozilla/camino/embed-replacements/locale/en-US/global/netError.dtd @@ -59,3 +59,9 @@ Attack sites try to install programs that steal private information, use your computer to attack others, or damage your system.You should not visit this site.
"> + + +Entering any personal information on this page may result in identity theft or other fraud. +These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.
+"> diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 9e0c5e4fa6e..1d33b089882 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2853,6 +2853,9 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, nsresult rv = NS_OK; nsAutoString messageStr; nsCAutoString cssClass; + nsCAutoString errorPage; + + errorPage.AssignLiteral("neterror"); // Turn the error code into a human readable error message. if (NS_ERROR_UNKNOWN_PROTOCOL == aError) { @@ -2947,6 +2950,25 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, } if (!messageStr.IsEmpty()) error.AssignLiteral("nssFailure2"); + } else if (NS_ERROR_PHISHING_URI == aError || NS_ERROR_MALWARE_URI == aError) { + nsCAutoString host; + aURI->GetHost(host); + CopyUTF8toUTF16(host, formatStrs[0]); + formatStrCount = 1; + + // Malware and phishing detectors may want to use an alternate error + // page, but if the pref's not set, we'll fall back on the standard page + nsXPIDLCString alternateErrorPage; + mPrefs->GetCharPref("urlclassifier.alternate_error_page", + getter_Copies(alternateErrorPage)); + if (alternateErrorPage) + errorPage.Assign(alternateErrorPage); + + if (NS_ERROR_PHISHING_URI == aError) + error.AssignLiteral("phishingBlocked"); + else + error.AssignLiteral("malwareBlocked"); + cssClass.AssignLiteral("blacklist"); } else { // Errors requiring simple formatting @@ -2993,15 +3015,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, // Bad Content Encoding. error.AssignLiteral("contentEncodingError"); break; - case NS_ERROR_MALWARE_URI: - nsCAutoString host; - aURI->GetHost(host); - CopyUTF8toUTF16(host, formatStrs[0]); - formatStrCount = 1; - - error.AssignLiteral("malwareBlocked"); - cssClass.AssignLiteral("blacklist"); - break; } } @@ -3042,8 +3055,8 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, // URI object. Missing URI objects are handled badly by session history. if (mUseErrorPages && aURI && aFailedChannel) { // Display an error page - LoadErrorPage(aURI, aURL, error.get(), messageStr.get(), - cssClass.get(), aFailedChannel); + LoadErrorPage(aURI, aURL, errorPage.get(), error.get(), + messageStr.get(), cssClass.get(), aFailedChannel); } else { @@ -3066,6 +3079,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI, NS_IMETHODIMP nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, + const char *aErrorPage, const PRUnichar *aErrorType, const PRUnichar *aDescription, const char *aCSSClass, @@ -3135,7 +3149,9 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, char *escapedDescription = nsEscape(NS_ConvertUTF16toUTF8(aDescription).get(), url_Path); char *escapedCSSClass = nsEscape(aCSSClass, url_Path); - nsCString errorPageUrl("about:neterror?e="); + nsCString errorPageUrl("about:"); + errorPageUrl.AppendASCII(aErrorPage); + errorPageUrl.AppendLiteral("?e="); errorPageUrl.AppendASCII(escapedError); errorPageUrl.AppendLiteral("&u="); diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index e44a8deb521..6dbd4eb2e0d 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -404,7 +404,8 @@ protected: const PRUnichar *aURL, nsIChannel* aFailedChannel = nsnull); NS_IMETHOD LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, - const PRUnichar *aPage, + const char *aErrorPage, + const PRUnichar *aErrorType, const PRUnichar *aDescription, const char *aCSSClass, nsIChannel* aFailedChannel); diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index d561c75893a..c146c498fd9 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1195,6 +1195,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, aStatus == NS_ERROR_NET_INTERRUPT || aStatus == NS_ERROR_NET_RESET || aStatus == NS_ERROR_MALWARE_URI || + aStatus == NS_ERROR_PHISHING_URI || NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) { DisplayLoadError(aStatus, url, nsnull, channel); } diff --git a/mozilla/dom/locales/en-US/chrome/appstrings.properties b/mozilla/dom/locales/en-US/chrome/appstrings.properties index b31d45522e7..2efa1b8fed8 100644 --- a/mozilla/dom/locales/en-US/chrome/appstrings.properties +++ b/mozilla/dom/locales/en-US/chrome/appstrings.properties @@ -60,3 +60,4 @@ externalProtocolUnknown=Attack sites try to install programs that steal private information, use your computer to attack others, or damage your system.
Web site owners who believe their site has been reported as an attack site in error may request a review.
"> + + +Entering any personal information on this page may result in identity theft or other fraud. +These types of web forgeries are used in scams known as phishing attacks, in which fraudulent web pages and emails are used to imitate sources you may trust.
+"> diff --git a/mozilla/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp b/mozilla/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp index 6991ed8d6b8..7ad3969172d 100644 --- a/mozilla/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp +++ b/mozilla/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp @@ -2107,6 +2107,13 @@ nsUrlClassifierClassifyCallback::HandleEvent(const nsACString& tables) tables.EndReading(end); if (FindInReadable(NS_LITERAL_CSTRING("-malware-"), begin, end)) { response = NS_ERROR_MALWARE_URI; + } else { + // Reset begin before checking phishing table + tables.BeginReading(begin); + + if (FindInReadable(NS_LITERAL_CSTRING("-phish-"), begin, end)) { + response = NS_ERROR_PHISHING_URI; + } } mCallback->OnClassifyComplete(response); diff --git a/mozilla/uriloader/base/nsURILoader.h b/mozilla/uriloader/base/nsURILoader.h index 854d364d767..2ef4ce74bdb 100644 --- a/mozilla/uriloader/base/nsURILoader.h +++ b/mozilla/uriloader/base/nsURILoader.h @@ -93,9 +93,10 @@ protected: }; /** - * The load has been cancelled because it was found on a malware blacklist. + * The load has been cancelled because it was found on a malware or phishing blacklist. * XXX: this belongs in an nsDocShellErrors.h file of some sort. */ #define NS_ERROR_MALWARE_URI NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_URILOADER, 30) +#define NS_ERROR_PHISHING_URI NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_URILOADER, 31) #endif /* nsURILoader_h__ */