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:
Against unchanged upstream: 25 new cases fail, 6 controls pass; all 31 pass with the fix.
Full python -m pytest -q, after importing the repository-pinned CLDR 48.2 and installing the missing tzdata package: 7862 passed, 7 skipped, 2 xfailed. One pytest deprecation warning points to an existing generator-based parametrization in test_toml_config.py.
pre-commit run --files babel/messages/jslexer.py tests/messages/test_js_line_continuations.py: passed.
Node.js independently confirms the runtime string values for 16 continuation/parity cases.
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.
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
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:
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.