You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/06/05 18:07:41 UTC
webworks commit: [CB-3435] Fixes a problem where the options in the
run command were not escaped properly
Updated Branches:
refs/heads/master 130461b0a -> b093a0cfb
[CB-3435] Fixes a problem where the options in the run command were not escaped properly
Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/b093a0cf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/b093a0cf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/b093a0cf
Branch: refs/heads/master
Commit: b093a0cfb0fbe9b7d81420410c22e1a02cd906ca
Parents: 130461b
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Wed Jun 5 11:16:35 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Wed Jun 5 12:10:18 2013 -0400
----------------------------------------------------------------------
.../project/cordova/lib/packager-utils.js | 25 ++++++++++-----
.../bin/templates/project/cordova/lib/plugin.js | 19 +++--------
blackberry10/bin/templates/project/cordova/lib/run | 17 ++++------
3 files changed, 30 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b093a0cf/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
index 09465e8..8bc3acf 100644
--- a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
@@ -49,12 +49,12 @@ _self = {
fs.writeFileSync(path.join(fileLocation, fileName), fileData);
},
-
+
copyFile: function (srcFile, destDir, baseDir) {
var filename = path.basename(srcFile),
fileBuffer = fs.readFileSync(srcFile),
fileLocation;
-
+
//if a base directory was provided, determine
//folder structure from the relative path of the base folder
if (baseDir && srcFile.indexOf(baseDir) === 0) {
@@ -65,27 +65,27 @@ _self = {
fs.writeFileSync(path.join(destDir, filename), fileBuffer);
}
},
-
+
listFiles: function (directory, filter) {
var files = wrench.readdirSyncRecursive(directory),
filteredFiles = [];
-
+
files.forEach(function (file) {
//On mac wrench.readdirSyncRecursive does not return absolute paths, so resolve one.
file = path.resolve(directory, file);
-
+
if (filter(file)) {
filteredFiles.push(file);
}
});
-
+
return filteredFiles;
},
isWindows: function () {
return os.type().toLowerCase().indexOf("windows") >= 0;
},
-
+
isArray: function (obj) {
return obj.constructor.toString().indexOf("Array") !== -1;
},
@@ -97,7 +97,7 @@ _self = {
}
return true;
},
-
+
toBoolean: function (myString, defaultVal) {
// if defaultVal is not passed, default value is undefined
return myString === "true" ? true : myString === "false" ? false : defaultVal;
@@ -170,7 +170,16 @@ _self = {
logger.info(msg);
}
}
+ },
+
+ escapeStringForShell: function (str) {
+ if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
+ return "\"" + str + "\"";
+ } else {
+ return str.replace(/(["\s'$`\\])/g,'\\$1');
+ }
}
+
};
module.exports = _self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b093a0cf/blackberry10/bin/templates/project/cordova/lib/plugin.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/plugin.js b/blackberry10/bin/templates/project/cordova/lib/plugin.js
index 1028422..7e1412c 100644
--- a/blackberry10/bin/templates/project/cordova/lib/plugin.js
+++ b/blackberry10/bin/templates/project/cordova/lib/plugin.js
@@ -22,8 +22,9 @@ var path = require("path"),
wrench = require("wrench"),
fs = require('fs'),
et = require('elementtree'),
+ escapeStringForShell = require("./packager-utils").escapeStringForShell,
PROJECT_ROOT = path.join(__dirname, "..", ".."),
- PLUGMAN = escapeShell(path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js")),
+ PLUGMAN = escapeStringForShell(path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js")),
GLOBAL_PLUGIN_PATH = require(path.join(PROJECT_ROOT, "project.json")).globalFetchDir,
LOCAL_PLUGIN_PATH = path.join(PROJECT_ROOT, "plugins"),
argumentor = {
@@ -45,21 +46,21 @@ var path = require("path"),
},
setProject: function () {
this.args.push("--project");
- this.args.push(escapeShell(PROJECT_ROOT));
+ this.args.push(escapeStringForShell(PROJECT_ROOT));
return argumentor;
},
setPlugin: function () {
var pluginWithoutTrailingSlash = this.plugin.charAt(this.plugin.length - 1) === "/" ? this.plugin.slice(0, -1) : this.plugin;
this.args.push("--plugin");
- this.args.push(escapeShell(pluginWithoutTrailingSlash));
+ this.args.push(escapeStringForShell(pluginWithoutTrailingSlash));
return argumentor;
},
setPluginsDir: function (isGlobal) {
this.args.push("--plugins_dir");
if (isGlobal) {
- this.args.push(escapeShell(GLOBAL_PLUGIN_PATH));
+ this.args.push(escapeStringForShell(GLOBAL_PLUGIN_PATH));
} else {
- this.args.push(escapeShell(LOCAL_PLUGIN_PATH));
+ this.args.push(escapeStringForShell(LOCAL_PLUGIN_PATH));
}
return argumentor;
},
@@ -88,14 +89,6 @@ var path = require("path"),
}
};
-function escapeShell(str) {
- if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
- return "\"" + str + "\"";
- } else {
- return str.replace(/(["\s'$`\\])/g,'\\$1');
- }
-}
-
function getPluginId(pluginXMLPath) {
var pluginEt = new et.ElementTree(et.XML(fs.readFileSync(pluginXMLPath, "utf-8")));
return pluginEt._root.attrib.id;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b093a0cf/blackberry10/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run b/blackberry10/bin/templates/project/cordova/lib/run
index 98ec9ea..f130dae 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -37,14 +37,11 @@ var childProcess = require("child_process"),
target,
ip,
password,
- workingdir,
- barPath;
+ workingdir = path.normalize(__dirname + "/..");
function generateOptions(uninstall) {
var options = [];
-
- workingdir = path.normalize(__dirname + "/.."),
- barPath = path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar");
+ barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar"));
options.push("-device");
options.push(ip);
@@ -104,24 +101,24 @@ function execNativeDeploy(optionsArray, callback) {
function checkTarget() {
if (!target) {
console.log("No target exists, to add that target please run target add <name> <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
- console.log(program.helpInformation());
+ console.log(program.helpInformation());
return false;
}
if (!properties.targets[target]) {
console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
- console.log(program.helpInformation());
+ console.log(program.helpInformation());
return false;
}
if (properties.targets[target].ip) {
- ip = properties.targets[target].ip;
+ ip = properties.targets[target].ip;
} else {
console.log("IP is not defined in target \""+target+"\"");
- console.log(program.helpInformation());
+ console.log(program.helpInformation());
return false;
}
if (properties.targets[target].password) {
password = properties.targets[target].password;
- }
+ }
return true;
}