You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2017/07/17 20:45:39 UTC
ios commit: CB-12966: (ios) Fix bug by escaping project name in
podfile template
Repository: cordova-ios
Updated Branches:
refs/heads/master 83435d56d -> 8edd13aae
CB-12966: (ios) Fix bug by escaping project name in podfile template
This closes #324
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8edd13aa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8edd13aa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8edd13aa
Branch: refs/heads/master
Commit: 8edd13aaee16d6996a4560a74d17798437b42c6f
Parents: 83435d5
Author: Josh Holtz <jo...@rokkincat.com>
Authored: Wed Jun 28 12:22:27 2017 -0500
Committer: Shazron Abdullah <sh...@gmail.com>
Committed: Mon Jul 17 13:45:26 2017 -0700
----------------------------------------------------------------------
bin/templates/scripts/cordova/lib/Podfile.js | 8 +++++++-
tests/spec/unit/Podfile.spec.js | 13 ++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8edd13aa/bin/templates/scripts/cordova/lib/Podfile.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/Podfile.js b/bin/templates/scripts/cordova/lib/Podfile.js
index 9dc35cf..49173c4 100644
--- a/bin/templates/scripts/cordova/lib/Podfile.js
+++ b/bin/templates/scripts/cordova/lib/Podfile.js
@@ -88,7 +88,13 @@ Podfile.prototype.__parseForPods = function (text) {
}, {});
};
+Podfile.prototype.escapeSingleQuotes = function (string) {
+ return string.replace('\'', '\\\'');
+};
+
Podfile.prototype.getTemplate = function () {
+ // Escaping possible ' in the project name
+ var projectName = this.escapeSingleQuotes(this.projectName);
return util.format(
'# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'platform :ios, \'8.0\'\n' +
@@ -96,7 +102,7 @@ Podfile.prototype.getTemplate = function () {
'\tproject \'%s.xcodeproj\'\n' +
'%s\n' +
'end\n',
- this.projectName, this.projectName, this.podToken);
+ projectName, projectName, this.podToken);
};
Podfile.prototype.addSpec = function (name, spec) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8edd13aa/tests/spec/unit/Podfile.spec.js
----------------------------------------------------------------------
diff --git a/tests/spec/unit/Podfile.spec.js b/tests/spec/unit/Podfile.spec.js
index b1fb13d..2d6e97c 100644
--- a/tests/spec/unit/Podfile.spec.js
+++ b/tests/spec/unit/Podfile.spec.js
@@ -138,9 +138,20 @@ describe('unit tests for Podfile module', function () {
expect(actualReleaseContents).toBe(expectedReleaseContents);
});
+ it('Test 010 : escapes single quotes in project name when writing a Podfile', function () {
+ podfile.before_install();
+
+ var projectName = 'This project\'s name';
+
+ var expectedProjectName = 'This project\\\'s name';
+ var actualProjectName = podfile.escapeSingleQuotes(projectName);
+
+ expect(actualProjectName).toBe(expectedProjectName);
+ });
+
});
- it('Test 010 : tear down', function () {
+ it('Test 011 : tear down', function () {
podfile.destroy();
var text = '// DO NOT MODIFY -- auto-generated by Apache Cordova\n';
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org