mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Check for invalid ASCII in the scanner
This commit is contained in:
parent
da189a6678
commit
8abc1a6863
@ -7,6 +7,7 @@ Breaking changes:
|
||||
* JSON AST: Remove members with ``null`` value from JSON output.
|
||||
* Parser: Disallow ``gwei`` as identifier.
|
||||
* Parser: Disallow dot syntax for ``value`` and ``gas``.
|
||||
* Parser: Disallow non-printable characters in string literals.
|
||||
* Parser: NatSpec comments on variables are only allowed for public state variables.
|
||||
* Parser: Remove the ``finney`` and ``szabo`` denominations.
|
||||
* Parser: Remove the identifier ``now`` (replaced by ``block.timestamp``).
|
||||
|
@ -73,6 +73,7 @@ string to_string(ScannerError _errorCode)
|
||||
case ScannerError::IllegalHexDigit: return "Hexadecimal digit missing or invalid.";
|
||||
case ScannerError::IllegalCommentTerminator: return "Expected multi-line comment-terminator.";
|
||||
case ScannerError::IllegalEscapeSequence: return "Invalid escape sequence.";
|
||||
case ScannerError::IllegalCharacterInString: return "Invalid character in string.";
|
||||
case ScannerError::IllegalStringEndQuote: return "Expected string end-quote.";
|
||||
case ScannerError::IllegalNumberSeparator: return "Invalid use of number separator '_'.";
|
||||
case ScannerError::IllegalExponent: return "Invalid exponent.";
|
||||
@ -789,7 +790,15 @@ Token Scanner::scanString()
|
||||
return setError(ScannerError::IllegalEscapeSequence);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Report error on non-printable characters in string literals.
|
||||
//
|
||||
// We are using a manual range and not isprint() to avoid
|
||||
// any potential complications with locale.
|
||||
if (static_cast<unsigned>(c) <= 0x1f || static_cast<unsigned>(c) >= 0x7f)
|
||||
return setError(ScannerError::IllegalCharacterInString);
|
||||
addLiteralChar(c);
|
||||
}
|
||||
}
|
||||
if (m_char != quote)
|
||||
return setError(ScannerError::IllegalStringEndQuote);
|
||||
|
@ -77,6 +77,7 @@ enum class ScannerError
|
||||
IllegalHexDigit,
|
||||
IllegalCommentTerminator,
|
||||
IllegalEscapeSequence,
|
||||
IllegalCharacterInString,
|
||||
IllegalStringEndQuote,
|
||||
IllegalNumberSeparator,
|
||||
IllegalExponent,
|
||||
|
Loading…
Reference in New Issue
Block a user