Repository navigation
Fix JavaScript line continuation decoding in extracted messages - #1385
Open
theman6660 wants to merge 2 commits into
Open
theman6660 wants to merge 2 commits into
theman6660 wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JavaScript source:
This evaluates to
helloworld, but Babel extracts a message containing an extra newline ("hello\nworld"). The initial regex substitution removes only the backslash and keeps the physical line break. It can also consume the second backslash of an escaped backslash before a template newline.Handle line continuations during the escape scan, recognizing LF, CR, CRLF, U+2028, and U+2029 and emitting no character, as specified by ECMAScript string literal semantics. Enable DOTALL for template string tokenization so escaped LF/CR sequences remain inside one token. Source line counting stays independent of decoded message content.
Add 31 cases covering all three quote forms, all five line terminator sequences in decoding, public extraction with source line numbers, ordinary escapes, and escaped-backslash parity.
Validation on Linux/Python 3.12.14:
python -m pytest -q, after importing the repository-pinned CLDR 48.2 and installing the missingtzdatapackage: 7862 passed, 7 skipped, 2 xfailed. One pytest deprecation warning points to an existing generator-based parametrization intest_toml_config.py.pre-commit run --files babel/messages/jslexer.py tests/messages/test_js_line_continuations.py: passed.git diff --check: passed; both remote files match the tested local files byte-for-byte.Prepared with OpenAI Codex assistance. The reproduction uses the public extraction API; no production usage or human review is claimed. Other Python versions and upstream CI remain unverified locally.