mirror of https://github.com/OpenTTD/OpenTTD
Fix: Validate raw strings from game-scripts, and strip invalid and control characters. (#13976)
parent
2cdf2bedfa
commit
3f2b58d6e1
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue