Skip to content

Escape value in CSS ~= attribute selector matching#319

Open
netliomax25-code wants to merge 1 commit into
itext:developfrom
netliomax25-code:css-attr-selector-quote-value
Open

Escape value in CSS ~= attribute selector matching#319
netliomax25-code wants to merge 1 commit into
itext:developfrom
netliomax25-code:css-attr-selector-quote-value

Conversation

@netliomax25-code

Copy link
Copy Markdown
  1. The ~= attribute selector in CssAttributeSelectorItem builds a regex from the selector value, so the value is treated as a pattern instead of a literal word.
  2. The value comes from untrusted CSS in an SVG/HTML document, so metacharacters change matching (for example a.c matches abc) and an unbalanced group such as ( throws an unchecked PatternSyntaxException during style resolution.
  3. Quoted the value with Pattern.quote before building the pattern, so it matches literally per the CSS ~= semantics.

@iText-CI

iText-CI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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.

2 participants