Skip to content

Fix string expression parsing for non-English contract text#62

Open
tinygrox wants to merge 3 commits intoKSP-RO:masterfrom
tinygrox:NonEnglishPaserFix
Open

Fix string expression parsing for non-English contract text#62
tinygrox wants to merge 3 commits intoKSP-RO:masterfrom
tinygrox:NonEnglishPaserFix

Conversation

@tinygrox
Copy link

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.

StringExpressionParser and related parser code were using regex patterns based on \w in a few places.

In .NET, \w matches Unicode, not just ASCII. That means translated text such as Chinese could accidentally match parser syntax that is intended to recognize identifiers and function calls

For example, strings like:

title = 发射@/targetBody1空间站!

could be parsed as though @/targetBody1空间站 were a single @xxx identifier, instead of @/targetBody1 followed by plain text.

Likewise, a string such as:

title = 安装部件(可选)

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:

title = 发射@/targetBody1空间站!

where:

发射 and 空间站! remain plain text,
@/targetBody1 is still parsed normally.

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.
@siimav
Copy link

siimav commented Mar 25, 2026

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.

@tinygrox
Copy link
Author

Well then, yay! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants