Skip to content

fix: decode quoted attribute line continuations - #353

Draft
Huzaifa-Asif wants to merge 1 commit into
postcss:mainfrom
Huzaifa-Asif:fix/quoted-attribute-line-continuations
Draft

Huzaifa-Asif wants to merge 1 commit into
postcss:mainfrom
Huzaifa-Asif:fix/quoted-attribute-line-continuations

Conversation

@Huzaifa-Asif

Copy link
Copy Markdown

Quoted attribute values currently retain escaped line breaks in their decoded value. Reading and assigning that value changes the selector's meaning: [title="a followed by a backslash, newline, and b"] matches title="ab", but the rewritten selector matches a value containing a newline.

Consume LF, CRLF, CR, and form-feed continuations when decoding quoted attribute strings, as specified by CSS string tokenization and input preprocessing. Keep original raw text for unchanged selectors. Add tests for both quote styles, value rewriting, escaped backslashes, and ordinary/hexadecimal escapes; correct the existing newline expectation to the decoded CSS value.

Validation on Node 24.18.1:

  • Pristine base: all 897 tests pass. With the revised regression tests and original implementation, 10 of 174 selected tests fail.
  • Fixed npm test: all 921 tests pass, including lint, declaration typecheck, build, and coverage thresholds (95.14% lines, 95.70% branches, 97.74% functions). Lint reports the same two pre-existing warnings in exceptions.mjs.
  • Eight native Chrome 155 checks confirm that both the original and rewritten selectors match title="ab", across both quote styles and all four newline encodings.
  • Changed-file formatting with repository-requested oxfmt 0.74.0 and git diff --check pass. Existing TypeScript 5.9.3, oxlint 1.78.0, and PostCSS 8.5.28 installations were reused; dependencies and lockfiles are unchanged.

AI assistance was used to investigate, implement, and test this change.

Preserve CSS string semantics when decoding and rewriting quoted attribute values. Add line continuation and escape boundary regression tests.

AI assistance was used for implementation, testing and independent automated review.
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