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

Unified Diff: lib/filterClasses.js

Issue 30045566: Fixed #4 - Disable rewrite option for all but internal redirect (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created April 15, 2019, 8:23 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: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -1055,21 +1055,20 @@
collapse = !inverse;
break;
case "sitekey":
if (!value)
return new InvalidFilter(origText, "filter_unknown_option");
sitekeys = value.toUpperCase();
break;
case "rewrite":
- if (value == null)
- return new InvalidFilter(origText, "filter_unknown_option");
+ if (!value.startsWith("abp-resource:"))
+ return new InvalidFilter(origText, "filter_invalid_rewrite");
rewrite = value;
- if (value.startsWith("abp-resource:"))
- resourceName = value.substr("abp-resource:".length);
+ resourceName = value.substr("abp-resource:".length);
break;
default:
return new InvalidFilter(origText, "filter_unknown_option");
}
}
}
}
@@ -1223,26 +1222,16 @@
* @param {string} url the URL to rewrite
* @return {string} the rewritten URL, or the original in case of failure
*/
rewriteUrl(url)
{
if (this.resourceName)
return resourceMap.get(this.resourceName) || url;
- try
- {
- let rewrittenUrl = new URL(url.replace(this.regexp, this.rewrite), url);
- if (rewrittenUrl.origin == new URL(url).origin)
- return rewrittenUrl.href;
- }
- catch (e)
- {
- }
-
return url;
}
});
/**
* Class for whitelist filters
* @param {string} text see {@link Filter Filter()}
* @param {string} regexpSource see {@link RegExpFilter RegExpFilter()}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld