Skip to content

Commit

Permalink
All exceptions filters are exempt from requiring a trusted source
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 14, 2023
1 parent 1e05665 commit d2b8d99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/js/scriptlet-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ const normalizeRawFilter = function(parser, sourceIsTrusted = false) {
if ( reng.aliases.has(token) ) {
token = reng.aliases.get(token);
}
if ( sourceIsTrusted !== true && reng.tokenRequiresTrust(token) ) {
return;
if ( parser.isException() !== true ) {
if ( sourceIsTrusted !== true ) {
if ( reng.tokenRequiresTrust(token) ) { return; }
}
}
args[0] = token.slice(0, -3);
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/static-filtering-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ export class AstFilterParser {
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
if ( realBad ) { break; }
if ( this.options.trustedSource !== true ) {
if ( isException !== true && this.options.trustedSource !== true ) {
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
realBad = true;
break;
Expand All @@ -1496,7 +1496,7 @@ export class AstFilterParser {
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM:
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
if ( realBad ) { break; }
if ( this.options.trustedSource !== true ) {
if ( isException !== true && this.options.trustedSource !== true ) {
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
realBad = true;
break;
Expand Down

0 comments on commit d2b8d99

Please sign in to comment.