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

Unified Diff: include.postload.js

Issue 5132310882025472: Issue 704 - Generate protocol-agnostic request blocking filters with "Block element" (Closed)
Patch Set: Created June 24, 2014, 3:20 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -279,11 +279,6 @@
else if (elt.src)
url = elt.src;
- // Only normalize when the element contains a URL (issue 328.)
- // The URL is not always normalized, so do it here
- if (url)
- url = normalizeURL(relativeToAbsoluteUrl(url));
-
// Construct filters. The popup will retrieve these.
// Only one ID
var elementId = elt.id ? elt.id.split(' ').join('') : null;
@@ -316,7 +311,9 @@
if (url)
{
- clickHideFilters.push(relativeToAbsoluteUrl(url));
+ url = relativeToAbsoluteUrl(url);
+
+ clickHideFilters.push(normalizeURL(url));
Wladimir Palant 2014/06/27 07:30:53 I wonder what will happen to src="about:blank" or
Sebastian Noack 2014/06/28 09:42:50 See http://codereview.adblockplus.org/594587757104
selectorList.push(elt.localName + '[src="' + url + '"]');
Wladimir Palant 2014/06/27 07:30:53 Just noticed - this one won't work correctly, it n
Sebastian Noack 2014/06/28 09:42:50 Done.
}
@@ -397,15 +394,13 @@
// Does some degree of URL normalization
function normalizeURL(url)
{
- var components = url.match(/(.+:\/\/.+?)\/(.*)/);
+ var components = url.match(/(.+:\/\/)(.+?)\/(.*)/);
Wladimir Palant 2014/06/27 07:30:53 We should really start using the URI class from ba
Sebastian Noack 2014/06/28 09:42:50 Any reasons why we "normalize" the URL in the firs
Sebastian Noack 2014/09/25 08:36:25 As discussed in http://codereview.adblockplus.org/
if(!components)
return url;
- var newPath = removeDotSegments(components[2]);
- if(newPath.length == 0)
- return components[1];
- if(newPath[0] != '/')
+ var newPath = removeDotSegments(components[3]);
+ if(newPath != '' && newPath[0] != '/')
Wladimir Palant 2014/06/27 07:30:53 It should actually be: newPath == "" || newPath[0]
Sebastian Noack 2014/06/28 09:42:50 Then you can just check for newPath[0] != "/" with
newPath = '/' + newPath;
- return components[1] + newPath;
+ return '||' + components[2] + newPath;
}
// Content scripts are apparently invoked on non-HTML documents, so we have to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld