aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-10-12 22:24:58 +0200
committerLars Knoll <lars.knoll@qt.io>2018-11-05 21:14:54 +0000
commit0fce92af2cab51d03f33230718ab5ae35149b9e1 (patch)
tree6367e64c4c2e6e2f3df02a2ccf6e2a1ae33cca0f
parent2cc77519ebf1b5e7249c1e2f6fec97816c068cd0 (diff)
Correctly read files with a \0 in them
At least one test case uses this, so let's make sure we read them correctly. Change-Id: I9f4ea7785b5a400cd6f0b210a6a98975bbbaf7ce Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations1
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp4
-rw-r--r--tools/qmljs/qmljs.cpp3
3 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index d51b45b75c..dddf5ace86 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -576,7 +576,6 @@ language/expressions/tagged-template/tco-member.js strictFails
language/expressions/tagged-template/template-object-frozen-non-strict.js sloppyFails
language/expressions/tagged-template/template-object-frozen-strict.js strictFails
language/expressions/tagged-template/template-object.js fails
-language/expressions/template-literal/tv-null-character-escape-sequence.js fails
language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
language/function-code/each-param-has-own-scope.js sloppyFails
language/function-code/eval-param-env-with-computed-key.js sloppyFails
diff --git a/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
index a16f2414b0..cbe3be2e70 100644
--- a/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
+++ b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
@@ -494,7 +494,7 @@ void Test262Runner::writeTestExpectations()
static bool executeTest(const QByteArray &data, bool runAsModule = false, const QString &testCasePath = QString(), const QByteArray &harnessForModules = QByteArray())
{
- QString testData = QString::fromUtf8(data);
+ QString testData = QString::fromUtf8(data.constData(), data.size());
QV4::ExecutionEngine vm;
@@ -514,7 +514,7 @@ static bool executeTest(const QByteArray &data, bool runAsModule = false, const
QFile f(url.toLocalFile());
if (f.open(QIODevice::ReadOnly)) {
QByteArray content = harnessForModules + f.readAll();
- module = vm.compileModule(url.toString(), QString::fromUtf8(content), QFileInfo(f).lastModified());
+ module = vm.compileModule(url.toString(), QString::fromUtf8(content.constData(), content.length()), QFileInfo(f).lastModified());
if (vm.hasException)
break;
vm.injectModule(module);
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 56d4a7d383..4b581fff05 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -146,7 +146,8 @@ int main(int argc, char *argv[])
}
}
if (!script) {
- const QString code = QString::fromUtf8(file.readAll());
+ QByteArray ba = file.readAll();
+ const QString code = QString::fromUtf8(ba.constData(), ba.length());
file.close();
script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn));