Bug 1269238 - allow text-links to use origin principals for link opening checks, r?mikedeboer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 06 May 2016 10:05:47 +0100
changeset 364246 4fb5f3f3baca236f5507235929d50c249abe3ebd
parent 364236 e65c3c2186710e9ee1dfb3f254bd45019ea34c80
child 520218 a4cdb50e2c035f1437552005f5b8940568580f0c
push id17394
push usergijskruitbosch@gmail.com
push dateFri, 06 May 2016 09:06:10 +0000
reviewersmikedeboer
bugs1269238
milestone49.0a1
Bug 1269238 - allow text-links to use origin principals for link opening checks, r?mikedeboer MozReview-Commit-ID: HPWxEyNEsps
browser/base/content/aboutDialog.xul
toolkit/content/widgets/text.xml
--- a/browser/base/content/aboutDialog.xul
+++ b/browser/base/content/aboutDialog.xul
@@ -124,32 +124,32 @@
           <vbox id="experimental" hidden="true">
             <description class="text-blurb" id="warningDesc">
               &warningDesc.version;
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
               &warningDesc.telemetryDesc;
 #endif
             </description>
             <description class="text-blurb" id="communityExperimentalDesc">
-              &community.exp.start;<label class="text-link" href="http://www.mozilla.org/">&community.exp.mozillaLink;</label>&community.exp.middle;<label class="text-link" href="about:credits">&community.exp.creditsLink;</label>&community.exp.end;
+              &community.exp.start;<label class="text-link" href="http://www.mozilla.org/">&community.exp.mozillaLink;</label>&community.exp.middle;<label class="text-link" useoriginprincipal="true" href="about:credits">&community.exp.creditsLink;</label>&community.exp.end;
             </description>
           </vbox>
           <description class="text-blurb" id="communityDesc">
-            &community.start2;<label class="text-link" href="http://www.mozilla.org/">&community.mozillaLink;</label>&community.middle2;<label class="text-link" href="about:credits">&community.creditsLink;</label>&community.end3;
+            &community.start2;<label class="text-link" href="http://www.mozilla.org/">&community.mozillaLink;</label>&community.middle2;<label class="text-link" useoriginprincipal="true" href="about:credits">&community.creditsLink;</label>&community.end3;
           </description>
           <description class="text-blurb" id="contributeDesc">
               &helpus.start;<label class="text-link" href="https://sendto.mozilla.org/page/contribute/Give-Now?source=mozillaorg_default_footer&#38;ref=firefox_about&#38;utm_campaign=firefox_about&#38;tm_source=firefox&#38;tm_medium=referral&#38;utm_content=20140929_FireFoxAbout">&helpus.donateLink;</label>&helpus.middle;<label class="text-link" href="http://www.mozilla.org/contribute/">&helpus.getInvolvedLink;</label>&helpus.end;
           </description>
         </vbox>
       </vbox>
     </hbox>
     <vbox id="bottomBox">
       <hbox pack="center">
-        <label class="text-link bottom-link" href="about:license">&bottomLinks.license;</label>
-        <label class="text-link bottom-link" href="about:rights">&bottomLinks.rights;</label>
+        <label class="text-link bottom-link" useoriginprincipal="true" href="about:license">&bottomLinks.license;</label>
+        <label class="text-link bottom-link" useoriginprincipal="true" href="about:rights">&bottomLinks.rights;</label>
         <label class="text-link bottom-link" href="https://www.mozilla.org/privacy/">&bottomLinks.privacy;</label>
       </hbox>
       <description id="trademark">&trademarkInfo.part1;</description>
     </vbox>
   </vbox>
   
   <keyset>
     <key keycode="VK_ESCAPE" oncommand="window.close();"/>
--- a/toolkit/content/widgets/text.xml
+++ b/toolkit/content/widgets/text.xml
@@ -309,20 +309,25 @@
                                .getService(nsISSM);
 
             const ioService =
                      Components.classes["@mozilla.org/network/io-service;1"]
                                .getService(Components.interfaces.nsIIOService);
 
             uri = ioService.newURI(href, null, null);
 
-            var nullPrincipal = secMan.createNullPrincipal({});
+            var principal;
+            if (this.getAttribute("useoriginprincipal") == "true") {
+              principal = this.nodePrincipal;
+            } else {
+              principal = secMan.createNullPrincipal({});
+            }
             try {
-              secMan.checkLoadURIWithPrincipal(nullPrincipal, uri,
-                                               nsISSM.DISALLOW_INHERIT_PRINCIPAL)
+              secMan.checkLoadURIWithPrincipal(principal, uri,
+                                               nsISSM.DISALLOW_INHERIT_PRINCIPAL);
             }
             catch (ex) {
               var msg = "Error: Cannot open a " + uri.scheme + ": link using \
                          the text-link binding.";
               Components.utils.reportError(msg);
               return;
             }