Bug 1342348 part 2 - Remove local link fix in about:reader. r?Gijs draft
authorXidorn Quan <me@upsuper.org>
Mon, 27 Feb 2017 12:06:38 +1100
changeset 490286 bc13431849ba1ad2d2e365ef92729545deb665af
parent 490285 625fb46bd4748c27725f62b30717e9982cd14fce
child 547216 7ec1e80fd1b4317737cc7d4d4bb008ef3b324286
push id47051
push userxquan@mozilla.com
push dateTue, 28 Feb 2017 01:07:01 +0000
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");