diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp index 6f167f2ccd..acfbd20861 100644 --- a/src/script/api/script_text.cpp +++ b/src/script/api/script_text.cpp @@ -201,9 +201,10 @@ void ScriptText::ParamCheck::Encode(std::back_insert_iterator &outp struct visitor { std::back_insert_iterator &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); } diff --git a/src/strings.cpp b/src/strings.cpp index f3cfd3081b..2ceaa0e1ec 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -126,7 +126,7 @@ EncodedString GetEncodedStringWithArgs(StringID str, std::span