Skip to content

Fix offsite URL performance with extra tests for policy change - #726

Open
spassarop wants to merge 1 commit into
mainfrom
offsiteurl-fixes
Open

Fix offsite URL performance with extra tests for policy change#726
spassarop wants to merge 1 commit into
mainfrom
offsiteurl-fixes

Conversation

@spassarop

Copy link
Copy Markdown
Collaborator

This PR refactors the offsiteURL and cssOffsiteUri regular expressions across all bundled policy files to improve matching efficiency and reduce evaluation overhead during policy checks.

  • Possessive quantifiers: Updated greedy loops (+, *) on character sets and whitespace to possessive quantifiers (++, *+). This prevents the regex engine from performing redundant backtracking attempts when evaluating non-matching or malformed inputs.
  • Group optimization: Replaced redundant capturing groups with streamlined non-capturing groups ((?:...)) for scheme matching.
  • Test suite expansion: Added execution timing benchmarks and expanded URL validation unit tests to verify both performance gains and syntax parity across supported protocols (http, https, ftp, ftps, mailto).

These changes should significantly accelerate evaluation speed and stabilize processing time on long string inputs. Also new tests try to prove no breaking changes to policy syntax handling or permitted URL formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant