Bug 1342348 part 2 - Remove local link fix in about:reader. r=Gijs
☠☠ backed out by 9c87e4453a8a ☠ ☠
authorXidorn Quan <me@upsuper.org>
Mon, 27 Feb 2017 12:06:38 +1100
changeset 374135 6e181ffefa618670a57a1a556afcd8a98b3fd8d5
parent 374134 4f0fce98dd3a7bdc4d4961a978f328e37bff615e
child 374136 3120e572493a77518e6960898f34afb9e0268f5b
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1342348
milestone54.0a1
Bug 1342348 part 2 - Remove local link fix in about:reader. r=Gijs MozReview-Commit-ID: GsEuRwj3oXV
toolkit/components/reader/AboutReader.jsm
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -734,31 +734,16 @@ AboutReader.prototype = {
 
       // The native locale could be set differently than the article's text direction.
       var localeDirection = gChromeRegistry.isLocaleRTL("global") ? "rtl" : "ltr";
       this._readTimeElement.setAttribute("dir", localeDirection);
       this._readTimeElement.style.textAlign = article.dir == "rtl" ? "right" : "left";
     }
   },
 
-  _fixLocalLinks() {
-    // We need to do this because preprocessing the content through nsIParserUtils
-    // gives back a DOM with a <base> element. That influences how these URLs get
-    // resolved, making them no longer match the document URI (which is
-    // about:reader?url=...). To fix this, make all the hash URIs absolute. This
-    // is hacky, but the alternative of removing the base element has potential
-    // security implications if Readability has not successfully made all the URLs
-    // absolute, so we pick just fixing these in-document links explicitly.
-    let localLinks = this._contentElement.querySelectorAll("a[href^='#']");
-    for (let localLink of localLinks) {
-      // Have to get the attribute because .href provides an absolute URI.
-      localLink.href = this._doc.documentURI + localLink.getAttribute("href");
-    }
-  },
-
   _formatReadTime(slowEstimate, fastEstimate) {
     let displayStringKey = "aboutReader.estimatedReadTimeRange1";
 
     // only show one reading estimate when they are the same value
     if (slowEstimate == fastEstimate) {
       displayStringKey = "aboutReader.estimatedReadTimeValue1";
     }
 
@@ -814,17 +799,16 @@ AboutReader.prototype = {
     this._headerElement.style.display = "block";
 
     let parserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
     let contentFragment = parserUtils.parseFragment(article.content,
       Ci.nsIParserUtils.SanitizerDropForms | Ci.nsIParserUtils.SanitizerAllowStyle,
       false, articleUri, this._contentElement);
     this._contentElement.innerHTML = "";
     this._contentElement.appendChild(contentFragment);
-    this._fixLocalLinks();
     this._maybeSetTextDirection(article);
     this._foundLanguage(article.language);
 
     this._contentElement.style.display = "block";
     this._updateImageMargins();
 
     this._requestFavicon();
     this._doc.body.classList.add("loaded");