Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: subscriptionLink.postload.js

Issue 29342971: Fixes 4065 - Subscription links on Chrome 30 (Closed)
Patch Set: Removed redundant comment Created May 24, 2016, 12:58 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 // Search the link associated with the click 36 // Search the link associated with the click
37 var link = event.target; 37 var link = event.target;
38 while (!(link instanceof HTMLAnchorElement)) 38 while (!(link instanceof HTMLAnchorElement))
39 { 39 {
40 link = link.parentNode; 40 link = link.parentNode;
41 41
42 if (!link) 42 if (!link)
43 return; 43 return;
44 } 44 }
45 45
46 let queryString = null;
46 if (link.protocol == "http:" || link.protocol == "https:") 47 if (link.protocol == "http:" || link.protocol == "https:")
47 { 48 {
48 if (link.host != "subscribe.adblockplus.org" || link.pathname != "/") 49 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
49 return; 50 queryString = link.search.substr(1);
50 } 51 }
51 else if (!/^abp:\/*subscribe\/*\?/i.test(link.href)) 52 else
53 {
54 // Old versions of Chrome (30) don't populate the "search" property for
55 // links with non-standard URL schemes so we need to extract the query
56 // string manually.
57 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
58 if (match)
59 queryString = match[1];
60 }
61
62 if (!queryString)
52 return; 63 return;
53 64
54 // This is our link - make sure the browser doesn't handle it 65 // This is our link - make sure the browser doesn't handle it
55 event.preventDefault(); 66 event.preventDefault();
56 event.stopPropagation(); 67 event.stopPropagation();
57 68
58 // Decode URL parameters 69 // Decode URL parameters
59 var params = link.search.substr(1).split("&"); 70 var params = queryString.split("&");
60 var title = null; 71 var title = null;
61 var url = null; 72 var url = null;
62 for (var i = 0; i < params.length; i++) 73 for (var i = 0; i < params.length; i++)
63 { 74 {
64 var parts = params[i].split("=", 2); 75 var parts = params[i].split("=", 2);
65 if (parts.length != 2 || !/\S/.test(parts[1])) 76 if (parts.length != 2 || !/\S/.test(parts[1]))
66 continue; 77 continue;
67 switch (parts[0]) 78 switch (parts[0])
68 { 79 {
69 case "title": 80 case "title":
(...skipping 18 matching lines...) Expand all
88 return; 99 return;
89 100
90 ext.backgroundPage.sendMessage({ 101 ext.backgroundPage.sendMessage({
91 type: "subscriptions.add", 102 type: "subscriptions.add",
92 title: title, 103 title: title,
93 url: url, 104 url: url,
94 confirm: true 105 confirm: true
95 }); 106 });
96 }, true); 107 }, true);
97 } 108 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld