diff --git a/platforms/android/cordova/lib/build.js b/platforms/android/cordova/lib/build.js index 84e4e02..95fa2ab 100755 --- a/platforms/android/cordova/lib/build.js +++ b/platforms/android/cordova/lib/build.js @@ -35,11 +35,11 @@ module.exports.run = function(build_type) { switch(build_type) { case '--debug' : clean.run(); - cmd = 'ant debug -f ' + path.join(ROOT, 'build.xml'); + cmd = ['ant', 'debug', '-f', path.join(ROOT, 'build.xml')]; break; case '--release' : clean.run(); - cmd = 'ant release -f ' + path.join(ROOT, 'build.xml'); + cmd = ['ant', 'release', '-f', path.join(ROOT, 'build.xml')]; break; case '--nobuild' : console.log('Skipping build...'); @@ -50,7 +50,7 @@ module.exports.run = function(build_type) { break; } if(cmd) { - var result = shell.exec(cmd, {silent:false, async:false}); + var result = shell.exec(cmd.join(' '), {silent:false, async:false}); if(result.code > 0) { console.error('ERROR: Failed to build android project.'); console.error(result.output); diff --git a/platforms/android/cordova/lib/clean.js b/platforms/android/cordova/lib/clean.js index 579a5fa..d52bc05 100755 --- a/platforms/android/cordova/lib/clean.js +++ b/platforms/android/cordova/lib/clean.js @@ -27,7 +27,12 @@ var shell = require('shelljs'), * Cleans the project using ant */ module.exports.run = function() { - var cmd = 'ant clean -f ' + path.join(ROOT, 'build.xml'); + var buildFilePath = path.join(ROOT, 'build.xml'); + if (!buildFilePath.startsWith(ROOT)) { + console.error('ERROR: Invalid build file path.'); + process.exit(2); + } + var cmd = 'ant clean -f ' + buildFilePath; var result = shell.exec(cmd, {silent:false, async:false}); if (result.code > 0) { console.error('ERROR: Failed to clean android project.'); diff --git a/platforms/android/cordova/lib/device.js b/platforms/android/cordova/lib/device.js index 46686b6..99370d8 100755 --- a/platforms/android/cordova/lib/device.js +++ b/platforms/android/cordova/lib/device.js @@ -40,7 +40,7 @@ module.exports.list = function() { var device_list = []; for (var i = 1; i < response.length; i++) { if (response[i].match(/\w+\tdevice/) && !response[i].match(/emulator/)) { - device_list.push(response[i].replace(/\tdevice/, '').replace('\r', '')); + device_list.push(response[i].replace(/\tdevice/, '').replace(/\r/g, '')); } } return device_list; diff --git a/platforms/android/cordova/lib/emulator.js b/platforms/android/cordova/lib/emulator.js index 6f8a7dd..4b47638 100755 --- a/platforms/android/cordova/lib/emulator.js +++ b/platforms/android/cordova/lib/emulator.js @@ -49,22 +49,22 @@ module.exports.list_images = function() { // To return more detailed information use img_obj var img_obj = {}; if (response[i].match(/Name:\s/)) { - img_obj['name'] = response[i].split('Name: ')[1].replace('\r', ''); + img_obj['name'] = response[i].split('Name: ')[1].replace(/\r/g, ''); if (response[i + 1].match(/Path:\s/)) { i++; - img_obj['path'] = response[i].split('Path: ')[1].replace('\r', ''); + img_obj['path'] = response[i].split('Path: ')[1].replace(/\r/g, ''); } if (response[i + 1].match(/\(API\slevel\s/)) { i++; - img_obj['target'] = response[i].replace('\r', ''); + img_obj['target'] = response[i].replace(/\r/g, ''); } if (response[i + 1].match(/ABI:\s/)) { i++; - img_obj['abi'] = response[i].split('ABI: ')[1].replace('\r', ''); + img_obj['abi'] = response[i].split('ABI: ')[1].replace(/\r/g, ''); } if (response[i + 1].match(/Skin:\s/)) { i++; - img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', ''); + img_obj['skin'] = response[i].split('Skin: ')[1].replace(/\r/g, ''); } emulator_list.push(img_obj); @@ -114,7 +114,7 @@ module.exports.list_started = function() { var started_emulator_list = []; for (var i = 1; i < response.length; i++) { if (response[i].match(/device/) && response[i].match(/emulator/)) { - started_emulator_list.push(response[i].replace(/\tdevice/, '').replace('\r', '')); + started_emulator_list.push(response[i].replace(/\tdevice/, '').replace(/\r/g, '')); } } return started_emulator_list; @@ -123,7 +123,7 @@ module.exports.list_started = function() { module.exports.get_target = function() { var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')); - return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', ''); + return target.split('=')[1].replace(/\n/g, '').replace(/\r/g, '').replace(' ', ''); } module.exports.list_targets = function() { diff --git a/platforms/blackberry10/cordova/lib/bbwpignore.js b/platforms/blackberry10/cordova/lib/bbwpignore.js index 29c6399..7bde32e 100755 --- a/platforms/blackberry10/cordova/lib/bbwpignore.js +++ b/platforms/blackberry10/cordova/lib/bbwpignore.js @@ -94,13 +94,13 @@ BBWPignore = function (bbwpIgnoreFile, filesToMatch) { //match wildCards wildcardEntries.forEach(function (wildcard) { if (wildcard.match("^/")) { // special case looking for exact match - wildcard = "^" + wildcard.replace("*", "[^\/]*"); + wildcard = "^" + wildcard.replace(/\*/g, "[^\/]*"); if (("/" + fileToMatch).match(wildcard)) { matched.push(fileToMatch); isMatch = true; } } else { - wildcard = wildcard.replace("*", "[^\/]*"); + wildcard = wildcard.replace(/\*/g, "[^\/]*"); if (fileToMatch.match(wildcard)) { matched.push(fileToMatch); isMatch = true; diff --git a/platforms/blackberry10/lib/cordova.3.1.0/javascript/cordova.js b/platforms/blackberry10/lib/cordova.3.1.0/javascript/cordova.js index c19ea6c..cb050c2 100644 --- a/platforms/blackberry10/lib/cordova.3.1.0/javascript/cordova.js +++ b/platforms/blackberry10/lib/cordova.3.1.0/javascript/cordova.js @@ -518,7 +518,7 @@ function include(parent, objects, clobber, merge) { */ function recursiveMerge(target, src) { for (var prop in src) { - if (src.hasOwnProperty(prop)) { + if (src.hasOwnProperty(prop)) { // Prevent prototype pollution if (target.prototype && target.prototype.constructor === target) { // If the target object is a constructor override off prototype. clobber(target.prototype, prop, src[prop]); @@ -1232,7 +1232,7 @@ function findCordovaPath() { var term = 'cordova.js'; for (var n = scripts.length-1; n>-1; n--) { var src = scripts[n].src; - if (src.indexOf(term) == (src.length - term.length)) { + if (src.indexOf(term) == (src.length - term.length) && src.indexOf(term) !== -1) { // Added check for -1 path = src.substring(0, src.length - term.length); break; } diff --git a/platforms/blackberry10/native/device/chrome/lib/policy/folderAccess.js b/platforms/blackberry10/native/device/chrome/lib/policy/folderAccess.js index b6e9f94..38b81ed 100644 --- a/platforms/blackberry10/native/device/chrome/lib/policy/folderAccess.js +++ b/platforms/blackberry10/native/device/chrome/lib/policy/folderAccess.js @@ -42,7 +42,7 @@ function _determineDepth(folderPath) { var depthCount = 0; // Replace all backslashes with forward slash - folderPath = folderPath.replace("\\", "/"); + folderPath = folderPath.replaceAll("\\", "/"); // Special case: "/" is the given path if (folderPath === "/") { @@ -75,7 +75,7 @@ function _getPath(folderPath, desiredDepth) { } // Replace all backslashes with forward slash - folderPath = folderPath.replace("\\", "/"); + folderPath = folderPath.replaceAll("\\", "/"); folderPath = _trimSurroundingSlashes(folderPath); diff --git a/platforms/blackberry10/native/device/chrome/lib/utils.js b/platforms/blackberry10/native/device/chrome/lib/utils.js index 4ab008a..80f8650 100644 --- a/platforms/blackberry10/native/device/chrome/lib/utils.js +++ b/platforms/blackberry10/native/device/chrome/lib/utils.js @@ -236,20 +236,20 @@ self = module.exports = { }, regexSanitize: function (regexString) { - return regexString.replace("^", "\\^") - .replace("$", "\\$") - .replace("(", "\\(") - .replace(")", "\\)") - .replace("<", "\\<") - .replace("[", "\\[") - .replace("{", "\\{") - .replace(/\\/, "\\\\") - .replace("|", "\\|") - .replace(">", "\\>") - .replace(".", "\\.") - .replace("*", "\\*") - .replace("+", "\\+") - .replace("?", "\\?"); + return regexString.replace(/\\/g, "\\\\") + .replace(/\^/g, "\\^") + .replace(/\$/g, "\\$") + .replace(/\(/g, "\\(") + .replace(/\)/g, "\\)") + .replace(//g, "\\>") + .replace(/\./g, "\\.") + .replace(/\*/g, "\\*") + .replace(/\+/g, "\\+") + .replace(/\?/g, "\\?"); }, find: function (comparison, collection, startInx, endInx, callback) { diff --git a/plugins/org.apache.cordova.device/test/cordova-incl.js b/plugins/org.apache.cordova.device/test/cordova-incl.js index a82c590..1be8a2e 100644 --- a/plugins/org.apache.cordova.device/test/cordova-incl.js +++ b/plugins/org.apache.cordova.device/test/cordova-incl.js @@ -67,7 +67,11 @@ if (PLAT) { if (!window._doNotWriteCordovaScript) { if (PLAT != "windows8") { - document.write(''); + var scriptElement = document.createElement('script'); + scriptElement.type = 'text/javascript'; + scriptElement.charset = 'utf-8'; + scriptElement.src = cordovaPath; + document.head.appendChild(scriptElement); } else { var s = document.createElement('script'); s.src = cordovaPath;