Give an error message when the sequence does not conform to the grammar.
Note that both \u and \x (without any numbers following it) are not
valid escape sequences in ECMA5.1.
Change-Id: I14348984c680b0ce86e05faad5630afc1e98cd02
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
// unicode escape sequence
case 'u':
u = decodeUnicodeEscapeCharacter(&ok);
- if (! ok)
- u = _char;
+ if (! ok) {
+ _errorCode = IllegalUnicodeEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+ return T_ERROR;
+ }
break;
// hex escape sequence
new TestCase( SECTION, "\\p", "p", "\p" );
new TestCase( SECTION, "\\q", "q", "\q" );
new TestCase( SECTION, "\\s", "s", "\s" );
-new TestCase( SECTION, "\\u", "u", "\u" );
new TestCase( SECTION, "\\w", "w", "\w" );
-new TestCase( SECTION, "\\x", "x", "\x" );
new TestCase( SECTION, "\\y", "y", "\y" );
new TestCase( SECTION, "\\z", "z", "\z" );
invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.2.qml";
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/numberParsing_error.1.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml";
}
--- /dev/null
+
+import QtQuick 2.0
+
+QtObject {
+ function code() {
+ var x = "\u000G";
+ }
+}
+
void tst_qqmlecmascript::stringParsing()
{
- for (int i = 1; i < 5; ++i) {
+ for (int i = 1; i < 6; ++i) {
QString file("stringParsing_error.%1.qml");
file = file.arg(i);
QQmlComponent component(&engine, testFileUrl(file));