Bug 1164426 - Build reader mode blocklist. r=margaret, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 15 May 2015 00:31:39 +0100
changeset 274639 3abaf0259599f944c9a5dbe87e5bee21489494bc
parent 274638 869b7584d26d274475127e2cc5808e63286fe8c6
child 274640 8518dcc3b49bbf47275ca9368a2337e9df808576
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1164426
milestone40.0a2
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
@@ -277,28 +277,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;
   },