New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ivy): i18n - ensure that colons in i18n metadata are not rendered #33820
fix(ivy): i18n - ensure that colons in i18n metadata are not rendered #33820
Conversation
35672c5
to
33f9a71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, except for debug-test.sh
and yarn.lock
that shouldn't be part of the PR! :)
33f9a71
to
a5df62c
Compare
Thanks @ocombe - I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
New set of g3 presubmits: |
@petebacondarwin g3 presubmit indicated the following problem:
Even though TS version requirement is satisfied. I sent you a message in Slack with additional info. |
119ea34
to
6ce72cc
Compare
From looking at the assertion - TS is re-parsing the raw text as though it was in the original source. For example if we are creating a simple no-substitution template literal with the text abc they put this back through their normal tokenizer (scanner) wrapped in backticks It is likely that the failing messages contain unescaped backticks or For example
In this case they would put it through the scanner as
which would obviously return only I have added a commit that escapes these sequences. |
6ce72cc
to
d4f2577
Compare
Thanks for the fix @petebacondarwin. I've restarted g3 presubmits with the most up-to-date version of this PR: |
Still fails with "Debug Failure. False expression: Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'." |
@petebacondarwin I performed additional investigation and here is the pattern that is causing failures in g3:
|
Thanks @AndrewKushnir - is the |
8080c75
to
4c52d4d
Compare
I have amended the last commit to also escape |
The `:` char is used as a metadata marker in `$localize` messages. If this char appears in the metadata it must be escaped, as `\:`. Previously, although the `:` char was being escaped, the TS AST being generated was not correct and so it was being output double escaped, which meant that it appeared in the rendered message. As of TS 3.6.2 the "raw" string can be specified when creating tagged template AST nodes, so it is possible to correct this.
Since i18n messages are mapped to `$localize` tagged template strings, the "raw" version must be properly escaped. Otherwise TS will throw an error such as: ``` Error: Debug Failure. False expression: Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'. ``` This commit ensures that we properly escape these raw strings before creating TS AST nodes from them.
4c52d4d
to
5e3d9a6
Compare
Thanks for the fix @petebacondarwin. I've started new presubmits: |
Hi @petebacondarwin, VE and Ivy presubmits look good with the most recent changes, so I've set the g3 status to "green" and removed the "blocked" label. Thanks for the fixes 👍 |
const STRING = /'(\\'|[^'])*'|"(\\"|[^"])*"/; | ||
const BACKTICK_STRING = /\\`(([\s\S]*?)(\$\{[^}]*?\})?)*?\\`/; | ||
const BACKTICK_STRING = /\\`(([\s\S]*?)(\$\{[^}]*?\})?)*?[^\\]\\`/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, what does the [^\\]
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-)
This is so that we can pick up escaped single quotes (i.e. \'
) that exist outside of single quoted strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I guess you don't need the capturing groups (because they will be messed up anyway 😁), right?
Nit: BTW, \$\{[^}]*?\}
doesn't need to be non-greedy: \$\{[^}]*\}
…#33820) The `:` char is used as a metadata marker in `$localize` messages. If this char appears in the metadata it must be escaped, as `\:`. Previously, although the `:` char was being escaped, the TS AST being generated was not correct and so it was being output double escaped, which meant that it appeared in the rendered message. As of TS 3.6.2 the "raw" string can be specified when creating tagged template AST nodes, so it is possible to correct this. PR Close #33820
…#33820) Since i18n messages are mapped to `$localize` tagged template strings, the "raw" version must be properly escaped. Otherwise TS will throw an error such as: ``` Error: Debug Failure. False expression: Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'. ``` This commit ensures that we properly escape these raw strings before creating TS AST nodes from them. PR Close #33820
…#33820) The `:` char is used as a metadata marker in `$localize` messages. If this char appears in the metadata it must be escaped, as `\:`. Previously, although the `:` char was being escaped, the TS AST being generated was not correct and so it was being output double escaped, which meant that it appeared in the rendered message. As of TS 3.6.2 the "raw" string can be specified when creating tagged template AST nodes, so it is possible to correct this. PR Close #33820
…#33820) Since i18n messages are mapped to `$localize` tagged template strings, the "raw" version must be properly escaped. Otherwise TS will throw an error such as: ``` Error: Debug Failure. False expression: Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'. ``` This commit ensures that we properly escape these raw strings before creating TS AST nodes from them. PR Close #33820
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The
:
char is used as a metadata marker in$localize
messages.If this char appears in the metadata it must be escaped, as
\:
.Previously, although the
:
char was being escaped, the TS ASTbeing generated was not correct and so it was being output double
escaped, which meant that it appeared in the rendered message.
As of TS 3.6.2 the "raw" string can be specified when creating tagged
template AST nodes, so it is possible to correct this.