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()} |