From e8c2e87397c0dbb8e5be3e096385e45740a4cbf3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 5 Aug 2016 18:27:44 +0100 Subject: Use utf8::validate in StringLiteral::toString --- libsolidity/ast/Types.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libsolidity/ast') diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index df4ec0aa..d6f6225c 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -854,6 +855,11 @@ bool StringLiteralType::operator==(const Type& _other) const std::string StringLiteralType::toString(bool) const { + int invalidSequence; + + if (!dev::utf8::validate(m_value, invalidSequence)) + return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")"; + return "literal_string \"" + m_value + "\""; } -- cgit