From 583d986a2b65447aea518d02e67bd3b6c80c2b59 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Fri, 17 May 2013 15:53:44 +0200 Subject: avoid wrong replacings in the load script code Change-Id: Ia0d437fe1200ffa692e7b9a204622619934e92a5 Reviewed-by: Karsten Heimrich --- src/libs/installer/scriptengine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libs/installer') diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index f7bb114f5..6178f467f 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -258,14 +258,14 @@ QScriptValue ScriptEngine::loadInConext(const QString &context, const QString &f // create inside closure in one line to keep linenumber in the right order // which is used as a debug output in an exception case + // scriptContent will be added as the last arg command to prevent wrong + // replacements of %1, %2 or %3 inside the scriptContent QString scriptContent = QString::fromLatin1( - "(function() { %1 %2 ; return new %3; })();"); + "(function() { %1 %3 ; return new %2; })();"); - scriptContent = scriptContent.arg(scriptInjection); - - // add file content to it - scriptContent = scriptContent.arg(QLatin1String(file.readAll())); - scriptContent = scriptContent.arg(context); + // merging everything together and as last we are adding the file content to prevent wrong + // replacements of %1 %2 or %3 inside the javascript code + scriptContent = scriptContent.arg(scriptInjection, context, QLatin1String(file.readAll())); QScriptValue scriptContext = evaluate(scriptContent, fileName); if (hasUncaughtException()) { -- cgit v1.2.3