mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #826 from axic/utf8-check
AST printer: do not output invalid UTF8 sequences
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -852,6 +853,16 @@ bool StringLiteralType::operator==(const Type& _other) const
|
||||
return m_value == dynamic_cast<StringLiteralType const&>(_other).m_value;
|
||||
}
|
||||
|
||||
std::string StringLiteralType::toString(bool) const
|
||||
{
|
||||
size_t invalidSequence;
|
||||
|
||||
if (!dev::validate(m_value, invalidSequence))
|
||||
return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")";
|
||||
|
||||
return "literal_string \"" + m_value + "\"";
|
||||
}
|
||||
|
||||
TypePointer StringLiteralType::mobileType() const
|
||||
{
|
||||
return make_shared<ArrayType>(DataLocation::Memory, true);
|
||||
|
||||
@@ -419,7 +419,7 @@ public:
|
||||
virtual bool canLiveOutsideStorage() const override { return false; }
|
||||
virtual unsigned sizeOnStack() const override { return 0; }
|
||||
|
||||
virtual std::string toString(bool) const override { return "literal_string \"" + m_value + "\""; }
|
||||
virtual std::string toString(bool) const override;
|
||||
virtual TypePointer mobileType() const override;
|
||||
|
||||
std::string const& value() const { return m_value; }
|
||||
|
||||
Reference in New Issue
Block a user