diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-10 22:06:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-11 14:50:32 +0100 |
commit | bac602c454f38ddde01167a3f75cb10ce1cfb876 (patch) | |
tree | 9e716db6d26ac6daeebc97c7bd29b37123f68a05 /src/qml/qml/parser | |
parent | f96f0083402ef0210192406aaa943b1b5297a584 (diff) |
Throw a parse error on octal numbers and escape sequences
This is compliant with EcmaScript 5.1, where octal numbers
and escape sequences are an optional and deprecated part
of the syntax.
Allow leading 0's in qml mode, but interpret the result
as decimal. This is also to keep compatibility with
existing code.
Change-Id: Ic3450ec3dd17966846751ee688a90c65939ba78f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/qml/qml/parser')
-rw-r--r-- | src/qml/qml/parser/qqmljslexer.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp index b53f16ca2c..0142e94db7 100644 --- a/src/qml/qml/parser/qqmljslexer.cpp +++ b/src/qml/qml/parser/qqmljslexer.cpp @@ -631,14 +631,24 @@ again: case 'v': u = QLatin1Char('\v'); scanChar(); break; case '0': - if (! _codePtr[1].isDigit()) { + if (! _codePtr->isDigit()) { scanChar(); u = QLatin1Char('\0'); - } else { - // ### parse deprecated octal escape sequence ? - u = _char; + break; } - break; + // fall through + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + _errorCode = IllegalEscapeSequence; + _errorMessage = QCoreApplication::translate("QQmlParser", "Octal escape sequences are not allowed"); + return T_ERROR; case '\r': if (isLineTerminatorSequence() == 2) { @@ -770,6 +780,10 @@ int Lexer::scanNumber(QChar ch) _tokenValue = integer; return T_NUMERIC_LITERAL; } + } else if (_char.isDigit() && !qmlMode()) { + _errorCode = IllegalCharacter; + _errorMessage = QCoreApplication::translate("QQmlParser", "Decimal numbers can't start with '0'"); + return T_ERROR; } QVarLengthArray<char,32> chars; |