aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-03-18 15:30:55 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-19 01:57:27 +0100
commita89a652bf5a9cb01ad2babc4c1374ba0b4d07edd (patch)
tree894fabdae7898cf02b5bb8b050506b5806585d8e /tests
parent9237c2ecb5c6fc8820c28a636d1112990c950bbe (diff)
Fix hexadecimal escape sequence validation in strings.
Give an error message when the sequence does not conform to the grammar. Although the specification does not explicitly state that this is an error, this is the behaviour of both JSC and V8. Change-Id: I34d189f07628bc6cc40b13bfbb8d09bee7810ced Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js3
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js3
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp1
-rw-r--r--tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml9
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp2
5 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
index 4a3173db6c..4b799f8df1 100644
--- a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
@@ -135,9 +135,10 @@ new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E
new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" );
// G is out of hex range
-
+/* Invalid testcase: we no longer silently ignore invalid hexadecimal escape sequences.
new TestCase( SECTION, "\\xG", "xG", "\xG" );
new TestCase( SECTION, "\\xCG", "xCG", "\xCG" );
+*/
// DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter
new TestCase( SECTION, "\\a", "a", "\a" );
diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
index 3e85ac7abf..f2dccd9267 100644
--- a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
@@ -55,7 +55,10 @@ startTest();
AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] );
AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] );
+
+/* Invalid testcase: we no longer silently ignore invalid hexadecimal escape sequences.
AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] );
+*/
AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] );
AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] );
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 2957a70d04..65549efddc 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -126,6 +126,7 @@ void tst_qmlmin::initTestCase()
invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.3.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.4.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml";
}
diff --git a/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml
new file mode 100644
index 0000000000..8ee5b59d9e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml
@@ -0,0 +1,9 @@
+
+import QtQuick 2.0
+
+QtObject {
+ function code() {
+ "\x0G"
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index d022e9dedc..06590f0ad6 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -7383,7 +7383,7 @@ void tst_qqmlecmascript::numberParsing()
void tst_qqmlecmascript::stringParsing()
{
- for (int i = 1; i < 6; ++i) {
+ for (int i = 1; i < 7; ++i) {
QString file("stringParsing_error.%1.qml");
file = file.arg(i);
QQmlComponent component(&engine, testFileUrl(file));