Skip to content

Commit

Permalink
Fix Safari DNR rule converter - drop unsupported regexps (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmod authored Oct 14, 2024
1 parent e039572 commit a014834
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/dnr-converter-safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ export function convert(r) {
);
}

// Based on https://github.com/w3c/webextensions/issues/344#issuecomment-1430358116
if (
rule.condition.regexFilter?.match(/(\{\d*,\d*\})/) ||
rule.condition.regexFilter?.match(/(\{\d+\})/)
) {
throw new Error(`regexp not supported: {n,m} quantifier`);
}

if (rule.condition.regexFilter?.match(/\(([^()]*[|][^()]*)\)/)) {
throw new Error(`regexp not supported : | - capture group disjunction`);
}

if (
rule.action.type === 'allowAllRequests' &&
(!rule.condition.resourceTypes ||
Expand Down

0 comments on commit a014834

Please sign in to comment.