Skip to content

fix: unescape adjacent bracket escapes - #341

Open
parijat1222q wants to merge 1 commit into
isaacs:mainfrom
parijat1222q:fix-adjacent-bracket-unescape
Open

parijat1222q wants to merge 1 commit into
isaacs:mainfrom
parijat1222q:fix-adjacent-bracket-unescape

Conversation

@parijat1222q

Copy link
Copy Markdown

Fixes #340.

The default-mode bracket pass consumes the character before a bracket escape. Adjacent escapes therefore only decode every other one: unescape('[a][b]') returns 'a[b]' instead of 'ab'.

Match and retain backslash-escaped characters in that pass rather than consuming a prefix before each bracket. This also lets a bracket escape after a paired backslash be decoded. Keep the following backslash pass and Windows-only behavior unchanged.

Tests cover adjacent bracket escapes, bracket-escaped escape() round trips, odd/even backslashes, both magicalBraces settings, Windows-only mode, and slash exclusions.

Validation on Linux/Node22.23.3:

  • New74 assertions:20 fail and54 pass on unchanged main; all74 pass with the fix.
  • npm test -- -c -t0:7068 assertions pass,36 test files, zero failures.
  • npm run prepare, npx oxlint src test, Prettier check on changed files, and git diff --check pass.

Other operating systems and Node versions have not been run locally.

This branch has not been deployed

No deployments
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.

unescape skips adjacent bracket escapes in default mode

1 participant