diff --git a/src/util/zstring.cpp b/src/util/zstring.cpp index aa5bdd665..5a57ec862 100644 --- a/src/util/zstring.cpp +++ b/src/util/zstring.cpp @@ -33,7 +33,7 @@ static bool is_hex_digit(char ch, unsigned& d) { return false; } -bool zstring::is_escape_char(char const *& s, unsigned& result) { +bool zstring::is_escape_char(bool from_input, char const *& s, unsigned& result) { unsigned d; if (*s == '\\' && s[1] == 'u' && s[2] == '{' && s[3] != '}') { result = 0; @@ -55,6 +55,8 @@ bool zstring::is_escape_char(char const *& s, unsigned& result) { } return false; } + if (!from_input) + return false; unsigned d1, d2, d3, d4; if (*s == '\\' && s[1] == 'u' && is_hex_digit(s[2], d1) && @@ -76,7 +78,7 @@ bool zstring::is_escape_char(char const *& s, unsigned& result) { zstring::zstring(char const* s, bool from_input) { while (*s) { unsigned ch = 0; - if (from_input && is_escape_char(s, ch)) { + if (is_escape_char(from_input, s, ch)) { m_buffer.push_back(ch); } else { diff --git a/src/util/zstring.h b/src/util/zstring.h index 6181240ca..f69a74ba5 100644 --- a/src/util/zstring.h +++ b/src/util/zstring.h @@ -25,7 +25,7 @@ private: buffer m_buffer; bool well_formed() const; bool uses_unicode() const; - bool is_escape_char(char const *& s, unsigned& result); + bool is_escape_char(bool from_input, char const *& s, unsigned& result); public: static unsigned unicode_max_char() { return 196607; } static unsigned unicode_num_bits() { return 18; }