summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-11-19 13:52:08 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2018-11-19 14:39:18 +0000
commit64ee4968b46019b8e4cb7523a6e41833fc4cf665 (patch)
tree66554a3705ae388aa30d7b8aa9ea44aa90052db9
parentec290770ff56791a62fde6f532e1b38e80f5b9bd (diff)
QML Lexer: Stop scanning template literals on closing '`'v5.12.0-rc2v5.12.0-rc1v5.12.0
Fixes: QTBUG-71812 Change-Id: I93b99496a7572c0f5128c69b865bb2b4f87d29af Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/qml/parser/qqmljslexer.cpp2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index b98bb8bac5..71885c533d 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -866,7 +866,7 @@ int Lexer::scanString(ScanStringMode mode)
if (sequenceLength == 2)
_tokenText += *_codePtr;
scanChar();
- } else if (_char == mode) {
+ } else if (_char == quote) {
scanChar();
if (_engine)
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 71c4e03812..254a6bc878 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -360,6 +360,7 @@ private slots:
void importLexicalVariables_data();
void importLexicalVariables();
void hugeObject();
+ void templateStringTerminator();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8858,6 +8859,14 @@ void tst_qqmlecmascript::hugeObject()
QVERIFY(!v.isError());
}
+void tst_qqmlecmascript::templateStringTerminator()
+{
+ QJSEngine engine;
+ const QJSValue value = engine.evaluate("let a = 123; let b = `x${a}\ny^`; b;");
+ QVERIFY(!value.isError());
+ QCOMPARE(value.toString(), QLatin1String("x123\ny^"));
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"