diff --git a/bin/templates/scripts/cordova/lib/Podfile.js b/bin/templates/scripts/cordova/lib/Podfile.js index 7106ff663..e78a1f3ab 100644 --- a/bin/templates/scripts/cordova/lib/Podfile.js +++ b/bin/templates/scripts/cordova/lib/Podfile.js @@ -168,7 +168,7 @@ Podfile.prototype.__parseForPods = function (text) { }; Podfile.prototype.escapeSingleQuotes = function (string) { - return string.replace('\'', '\\\''); + return string.replace(/'/g, '\\\''); }; Podfile.prototype.getTemplate = function () { diff --git a/tests/spec/unit/Podfile.spec.js b/tests/spec/unit/Podfile.spec.js index 9618c3943..96be921d4 100644 --- a/tests/spec/unit/Podfile.spec.js +++ b/tests/spec/unit/Podfile.spec.js @@ -153,9 +153,20 @@ describe('unit tests for Podfile module', function () { expect(actualProjectName).toBe(expectedProjectName); }); + it('Test 011 : escapes double single quotes in project name when writing a Podfile', function () { + podfile.before_install(); + + var projectName = 'l\'etat c\'est moi'; + + var expectedProjectName = 'l\\\'etat c\\\'est moi'; + var actualProjectName = podfile.escapeSingleQuotes(projectName); + + expect(actualProjectName).toBe(expectedProjectName); + }); + }); - it('Test 011 : tear down', function () { + it('Test 012 : tear down', function () { podfile.destroy(); var text = '// DO NOT MODIFY -- auto-generated by Apache Cordova\n';