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: Update tests. Created April 15, 2019, 8:52 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 | test/filterClasses.js » ('j') | test/filterClasses.js » ('J')
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:"))
Manish Jethani 2019/04/15 21:26:37 `value` could still be `null`?
hub 2019/04/16 04:56:24 Yeah. I'll simplify this now that we are going the
+ 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;
Manish Jethani 2019/04/15 21:26:37 If `resourceName` is `undefined` or `null` then I'
hub 2019/04/16 04:56:23 Done.
- 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 | test/filterClasses.js » ('j') | test/filterClasses.js » ('J')

Powered by Google App Engine
This is Rietveld