[Pkg-mozext-commits] [adblock-plus] 52/74: Issue 2211 - Implemented subscribe.adblockplus.org subscription links

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 12:07:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 0ccda2450f346c9b47fedbf5996c5e45d4c2bff4
Author: Thomas Greiner <thomas at adblockplus.org>
Date:   Mon Jul 20 16:39:32 2015 +0200

    Issue 2211 - Implemented subscribe.adblockplus.org subscription links
---
 lib/ui.js | 54 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/lib/ui.js b/lib/ui.js
index 761256b..d2c6327 100644
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -924,43 +924,53 @@ let UI = exports.UI =
 
   /**
    * Handles clicks inside the browser's content area, will intercept clicks on
-   * abp: links. This can be called either with an event object or with the link
-   * target (if it is the former then link target will be retrieved from event
-   * target).
+   * abp: links as well as links to subscribe.adblockplus.org.
    */
-  onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ linkTarget)
+  onBrowserClick: function (/**Window*/ window, /**Event*/ event)
   {
-    if (event)
-    {
-      // Ignore right-clicks
-      if (event.button == 2)
-        return;
+    // Ignore right-clicks
+    if (event.button == 2)
+      return;
 
-      // Search the link associated with the click
-      let link = event.target;
-      while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement))
-        link = link.parentNode;
+    // Search the link associated with the click
+    let link = event.target;
+    while (!(link instanceof Ci.nsIDOMHTMLAnchorElement))
+    {
+      link = link.parentNode;
 
-      if (!link || link.protocol != "abp:")
+      if (!link)
         return;
+    }
 
-      // This is our link - make sure the browser doesn't handle it
-      event.preventDefault();
-      event.stopPropagation();
-
-      linkTarget = link.href;
+    let queryString = null;
+    if (link.protocol == "http:" || link.protocol == "https:")
+    {
+      if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
+        queryString = link.search.substr(1);
+    }
+    else
+    {
+      // Firefox doesn't populate the "search" property for links with
+      // non-standard URL schemes so we need to extract the query string
+      // manually
+      let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
+      if (match)
+        queryString = match[1];
     }
 
-    let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget);
-    if (!match)
+    if (!queryString)
       return;
 
+    // This is our link - make sure the browser doesn't handle it
+    event.preventDefault();
+    event.stopPropagation();
+
     // Decode URL parameters
     let title = null;
     let url = null;
     let mainSubscriptionTitle = null;
     let mainSubscriptionURL = null;
-    for (let param of match[1].split('&'))
+    for (let param of queryString.split("&"))
     {
       let parts = param.split("=", 2);
       if (parts.length != 2 || !/\S/.test(parts[1]))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list