Fix string expression parsing for non-English contract text#62
Open
tinygrox wants to merge 3 commits intoKSP-RO:masterfrom
Open
Fix string expression parsing for non-English contract text#62tinygrox wants to merge 3 commits intoKSP-RO:masterfrom
tinygrox wants to merge 3 commits intoKSP-RO:masterfrom
Conversation
Replace \w-based string expression matching with explicit ASCII identifier rules so non-English contract text is not mistaken for function calls or identifier content.
|
I have consulted with a bunch of people and the conclusion is that we should instead use some kind of delimiter for the expression syntax. |
Author
|
Well then, yay! 😃 |
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.
This PR fixed a parsing issue where translated contract text could be misinterpreted as expression syntax.
In particular, non-English text in string fields such as title, description, synopsis, notes, and completedMessage could be incorrectly treated as function names or as part of an @... identifier.
StringExpressionParserand related parser code were using regex patterns based on\win a few places.In .NET,
\wmatches Unicode, not just ASCII. That means translated text such as Chinese could accidentally match parser syntax that is intended to recognize identifiers and function callsFor example, strings like:
could be parsed as though
@/targetBody1空间站were a single@xxxidentifier, instead of@/targetBody1followed by plain text.Likewise, a string such as:
could be treated as though it began with a function call, because the old
\w-based matching considered the leading Chinese text to be a valid identifier.After changes, the following works as expected:
where:
发射and空间站!remain plain text,@/targetBody1is still parsed normally.