summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-04-10 11:07:09 +0200
committerKai Koehne <kai.koehne@digia.com>2014-04-23 13:35:53 +0200
commitf91f630fa2294d70f27c4c88dfa331a9f81f5387 (patch)
tree88c4bb900f0bbe58d7179e6de8936ed9819af314
parentb138cbfed60815b26b417a308a8fee824dab5228 (diff)
Make sure we read the script content as UTF8.
Task-number: QTIFW-485 Change-Id: Id09365207c6f5b1312fb85ad67443f7e51a1944e Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r--src/libs/installer/scriptengine.cpp12
-rw-r--r--tools/common/repositorygen.cpp8
2 files changed, 10 insertions, 10 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index d46805ade..9908ce29d 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -252,14 +252,14 @@ QScriptValue ScriptEngine::loadInConext(const QString &context, const QString &f
// Create a closure. Put the content in the first line to keep line number order in case of an
// exception. Script content will be added as the last argument to the command to prevent wrong
// replacements of %1, %2 or %3 inside the javascript code.
- QString scriptContent = QString::fromLatin1(
- "(function() {"
- " %1 %3 ;"
- " if (typeof %2 != \"undefined\")"
- " return new %2;"
+ const QString scriptContent = QLatin1String("(function() {")
+ + scriptInjection + QString::fromUtf8(file.readAll())
+ + QString::fromLatin1(";"
+ " if (typeof %1 != \"undefined\")"
+ " return new %1;"
" else"
" throw \"Missing Component constructor. Please check your script.\";"
- "})();").arg(scriptInjection, context, QLatin1String(file.readAll()));
+ "})();").arg(context);
QScriptValue scriptContext = evaluate(scriptContent, fileName);
if (hasUncaughtException()) {
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp
index 11063e789..a5634f25f 100644
--- a/tools/common/repositorygen.cpp
+++ b/tools/common/repositorygen.cpp
@@ -299,12 +299,12 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
.arg(scriptFile.fileName()));
}
- QString scriptContent = QString::fromLatin1(
- "(function() {"
- " %1;"
+ const QString scriptContent = QLatin1String("(function() {")
+ + QString::fromUtf8(scriptFile.readAll())
+ + QLatin1String(";"
" if (typeof Component == \"undefined\")"
" throw \"Missing Component constructor. Please check your script.\";"
- "})();").arg(QTextStream(&scriptFile).readAll());
+ "})();");
// if the user isn't aware of the downloadable archives value we will add it automatically later
foundDownloadableArchives |= scriptContent.contains(QLatin1String("addDownloadableArchive"))