Bug 296952 - Improve Phishing Detector to recognize host names of the same domain (address review comments); r=mkmelin
authorJim Porter <jporter@mozilla.com>
Mon, 27 Jan 2014 20:12:14 -0600
changeset 15668 dc59ad3ee2f7223e0dd40b35a4eefb7cb3306e39
parent 15667 887255521bffafa5ad87c901c7a58f897f13117d
child 15669 63f631f47649162da892c99c84f9a2a674c3faef
push id9817
push usersquibblyflabbetydoo@gmail.com
push dateTue, 28 Jan 2014 02:12:23 +0000
treeherdercomm-central@dc59ad3ee2f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs296952
Bug 296952 - Improve Phishing Detector to recognize host names of the same domain (address review comments); r=mkmelin
mail/base/content/phishingDetector.js
mail/test/mozmill/message-header/test-phishing-bar.js
--- a/mail/base/content/phishingDetector.js
+++ b/mail/base/content/phishingDetector.js
@@ -19,19 +19,19 @@ var gPhishingDetector = {
   shutdown: function()
   {
     try {
       this.mPhishingWarden.shutdown();
     } catch (ex) {}
   },
 
   /**
-   * initialize the phishing warden.
-   * initialize the black and white list url tables.
-   * update the local tables if necessary
+   * Initialize the phishing warden.
+   * Initialize the black and white list url tables.
+   * Update the local tables if necessary.
    */
   init: function()
   {
     Components.utils.import("resource:///modules/hostnameUtils.jsm", this);
 
     try {
       // set up the anti phishing service
       var appContext = Components.classes["@mozilla.org/phishingprotection/application;1"]
@@ -218,27 +218,24 @@ var gPhishingDetector = {
    */
   misMatchedHostWithLinkText: function(aHrefURL, aLinkNodeText)
   {
     // gatherTextUnder puts a space between each piece of text it gathers,
     // so strip the spaces out (see bug 326082 for details).
     aLinkNodeText = aLinkNodeText.replace(/ /g, "");
 
     // Only worry about http: and https: urls.
-    if (aLinkNodeText && aLinkNodeText.search(/(^https?:)/) != -1)
+    if (/^https?:/.test(aLinkNodeText))
     {
-      let eTLD = Components.classes["@mozilla.org/network/effective-tld-service;1"]
-                           .getService(Components.interfaces.nsIEffectiveTLDService);
-
       let linkTextURI = Services.io.newURI(aLinkNodeText, null, null);
 
       // Compare the base domain of the href and the link text.
       try {
-        return eTLD.getBaseDomain(aHrefURL) !=
-               eTLD.getBaseDomain(linkTextURI);
+        return Services.eTLD.getBaseDomain(aHrefURL) !=
+               Services.eTLD.getBaseDomain(linkTextURI);
       } catch (e) {
         // If we throw above, one of the URIs probably has no TLD (e.g.
         // http://localhost), so just check the entire host.
         return aHrefURL.host != linkTextURI.host;
       }
     }
 
     return false;
--- a/mail/test/mozmill/message-header/test-phishing-bar.js
+++ b/mail/test/mozmill/message-header/test-phishing-bar.js
@@ -146,12 +146,8 @@ function test_no_phishing_warning_for_su
  * Test that when viewing a message with a link where the text and/or href
  * has no TLD, we still warn as appropriate.
  */
 function test_phishing_warning_for_local_domain() {
   be_in_folder(folder);
   select_click_row(5);
   assert_notification_displayed(mc, kBoxId, kNotificationValue, true); // shown
 }
-
-
-
-