Bug 1164426 - Build reader mode blocklist. r=margaret, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 15 May 2015 00:31:39 +0100
changeset 260520 6ec85b777880
parent 260519 24524667128b
child 260521 4bfd19d00ed4
push id805
push userryanvm@gmail.com
push date2015-05-18 17:06 +0000
treeherdermozilla-release@4bfd19d00ed4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1164426
milestone38.0.5
Bug 1164426 - Build reader mode blocklist. r=margaret, a=sledru
toolkit/components/reader/ReaderMode.jsm
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -273,28 +273,41 @@ this.ReaderMode = {
     yield OS.File.remove(path);
   }),
 
   log: function(msg) {
     if (this.DEBUG)
       dump("Reader: " + msg);
   },
 
+  _blockedHosts: [
+    "twitter.com",
+    "mail.google.com",
+    "github.com",
+    "reddit.com",
+  ],
+
   _shouldCheckUri: function (uri) {
     if (!(uri.schemeIs("http") || uri.schemeIs("https") || uri.schemeIs("file"))) {
       this.log("Not parsing URI scheme: " + uri.scheme);
       return false;
     }
 
     try {
       uri.QueryInterface(Ci.nsIURL);
     } catch (ex) {
       // If this doesn't work, presumably the URL is not well-formed or something
       return false;
     }
+    // Sadly, some high-profile pages have false positives, so bail early for those:
+    let asciiHost = uri.asciiHost;
+    if (this._blockedHosts.some(blockedHost => asciiHost.endsWith(blockedHost))) {
+      return false;
+    }
+
     if (!uri.filePath || uri.filePath == "/") {
       this.log("Not parsing home page: " + uri.spec);
       return false;
     }
 
     return true;
   },