1
0
Fork 0

Fix: Validate raw strings from game-scripts, and strip invalid and control characters. (#13976)

pull/13655/head
frosch 2025-04-07 19:30:36 +02:00 committed by GitHub
parent 2cdf2bedfa
commit 3f2b58d6e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -201,9 +201,10 @@ void ScriptText::ParamCheck::Encode(std::back_insert_iterator<std::string> &outp
struct visitor {
std::back_insert_iterator<std::string> &output;
void operator()(const std::string &value)
void operator()(std::string value)
{
Utf8Encode(this->output, SCC_ENCODED_STRING);
StrMakeValidInPlace(value, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE | SVS_REPLACE_TAB_CR_NL_WITH_SPACE);
fmt::format_to(this->output, "{}", value);
}

View File

@ -126,7 +126,7 @@ EncodedString GetEncodedStringWithArgs(StringID str, std::span<const StringParam
char32_t c;
const char *p = value.data();
if (Utf8Decode(&c, p)) {
assert(c != SCC_ENCODED && c != SCC_ENCODED_INTERNAL);
assert(c != SCC_ENCODED && c != SCC_ENCODED_INTERNAL && c != SCC_RECORD_SEPARATOR);
}
}
#endif /* WITH_ASSERT */