Bail out on stray newlines in strings in JS mode
authorLars Knoll <lars.knoll@digia.com>
Tue, 11 Dec 2012 06:51:22 +0000 (07:51 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 11 Dec 2012 13:50:32 +0000 (14:50 +0100)
Still allow newlines in QML mode to keep compatibility
for existing code.

Change-Id: I11dbd5a73ea8958f5ddc199b77a919969f8a5214
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>

src/qml/qml/parser/qqmljslexer.cpp

index 4e15065..158640c 100644 (file)
@@ -610,7 +610,13 @@ again:
 
         if (_engine) {
             while (!_char.isNull()) {
-                if (isLineTerminator() || _char == QLatin1Char('\\')) {
+                if (isLineTerminator()) {
+                    if (qmlMode())
+                        break;
+                    _errorCode = IllegalCharacter;
+                    _errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal");
+                    return T_ERROR;
+                } else if (_char == QLatin1Char('\\')) {
                     break;
                 } else if (_char == quote) {
                     _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);