diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-08-06 01:27:44 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2016-08-09 02:57:41 +0800 |
commit | e8c2e87397c0dbb8e5be3e096385e45740a4cbf3 (patch) | |
tree | 33b0a77171ac3e11addba30728067f7756364ec6 | |
parent | 7945f41ccc63510a3fcb68d7c00e0c48143c4ed3 (diff) | |
download | dexon-solidity-e8c2e87397c0dbb8e5be3e096385e45740a4cbf3.tar.gz dexon-solidity-e8c2e87397c0dbb8e5be3e096385e45740a4cbf3.tar.zst dexon-solidity-e8c2e87397c0dbb8e5be3e096385e45740a4cbf3.zip |
Use utf8::validate in StringLiteral::toString
-rw-r--r-- | libsolidity/ast/Types.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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 <libdevcore/CommonIO.h> #include <libdevcore/CommonData.h> #include <libdevcore/SHA3.h> +#include <libdevcore/UTF8.h> #include <libsolidity/interface/Utils.h> #include <libsolidity/ast/AST.h> @@ -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 + "\""; } |