Repository navigation
Conversation
Member
|
We do not accept AI slop contributions that are opened without considerations of the project. Thank you for your understanding. |
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #71915
An interpolation ends early when a regex literal inside it contains
}}, for example{{ /[}}]/u.test('}') }}. The template lexer (_consumeInterpolationinpackages/compiler/src/ml_parser/lexer.ts) only tracks quotes and//comments while looking for the closing}}, so the}}inside the regex is mistaken for the end of the interpolation. The expression parser (_getInterpolationEndIndex/_forEachUnquotedCharinpackages/compiler/src/expression_parser/parser.ts) has the same gap, which is the path hit by e.g.titleinterpolations.What is the new behavior?
Both scanners now skip over regex literals while looking for the end of an interpolation. Whether a
/starts a regex literal or is a division operator is decided from the previous significant characters, mirroringisStartOfRegex()in the expression lexer (regex after an operator,(,[,,or:or at the start of the expression; division after a value such as an identifier, a number,)or];!is treated as a negation vs. a non-null assertion the same way the expression lexer treats it). A regex is only skipped when a closing/is found on the same line, so an unterminated regex keeps its previous behavior instead of swallowing the rest of the template. Division is unaffected:{{ 6 / 2 }},{{ a / b }}and{{ /a/ / 2 }}still parse as before.Does this PR introduce a breaking change?
Other information
Tests run (locally, with the repo's own spec files run under Jasmine via an esbuild bundle, since Bazel was not available in this environment):
ml_parser/lexer_spec.ts("should parse interpolation with a regex literal containing }}") andexpression_parser/parser_spec.ts("should parse interpolation with a regex literal containing }}", "should still treat a slash after a value as division in interpolation").packages/compiler/test/ml_parser/lexer_spec.ts,ast_serializer_spec.ts,html_parser_spec.ts,html_whitespaces_spec.ts,inline_comment_spec.ts,packages/compiler/test/expression_parser/ast_spec.ts,lexer_spec.ts,parser_spec.ts,serializer_spec.ts.tsc --noEmitis clean for the two changed source files.{{ /[}}]/u.test('}') }}in text and in atitleattribute, plus{{ /}}/.test('}}') }}and{{ 6 / 2 }}) parse throughHtmlParserandParser.parseInterpolationwith no errors.