cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13948) Apps with ampersand (&) in the name throw build error in cordova-ios@4.3.1
Date Thu, 08 Mar 2018 14:03:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16391272#comment-16391272
] 

ASF GitHub Bot commented on CB-13948:
-------------------------------------

ronaldozanoni closed pull request #362: CB-13948 Properly encode app name to generate XML
files using cordova-ios 4.3.1
URL: https://github.com/apache/cordova-ios/pull/362
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CordovaLib/VERSION b/CordovaLib/VERSION
index f77856a6f..cc2fbe89b 100644
--- a/CordovaLib/VERSION
+++ b/CordovaLib/VERSION
@@ -1 +1 @@
-4.3.1
+4.3.2
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 29be90991..9aa3d4bf3 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -8,9 +8,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
      http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var PLATFORM_VERSION_BUILD_LABEL = '4.3.1';
+var PLATFORM_VERSION_BUILD_LABEL = '4.3.2';
 // file: src/scripts/require.js
 
 /*jshint -W079 */
@@ -962,7 +962,7 @@ function iOSExec() {
 // CB-10530
 function proxyChanged() {
     var cexec = cordovaExec();
-       
+
     return (execProxy !== cexec && // proxy objects are different
             iOSExec !== cexec      // proxy object is not the current iOSExec
             );
@@ -979,14 +979,14 @@ function handleBridgeChange() {
             var action = command[2];
             var actionArgs = command[3];
             var callbacks = cordova.callbacks[callbackId] || {};
-            
+
             execProxy(callbacks.success, callbacks.fail, service, action, actionArgs);
-            
+
             commandString = commandQueue.shift();
         };
         return true;
     }
-    
+
     return false;
 }
 
@@ -996,7 +996,7 @@ function pokeNative() {
         setTimeout(pokeNative);
         return;
     }
-    
+
     // Check if they've removed it from the DOM, and put it back if so.
     if (execIframe && execIframe.contentWindow) {
         execIframe.contentWindow.location = 'gap://ready';
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 89b9c8a9f..d62a44cd5 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -24,6 +24,7 @@ var shell = require('shelljs'),
     path = require('path'),
     fs = require('fs'),
     plist = require('plist'),
+    xmlescape = require('xml-escape'),
     ROOT = path.join(__dirname, '..', '..'),
     events = require('cordova-common').events;
 
@@ -145,10 +146,14 @@ function copyTemplateFiles(project_path, project_name, project_template_dir,
pac
      * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-info.plist
      * - ./__PROJECT_NAME__/Resources/__PROJECT_NAME__-Prefix.plist
      */
+
+    // https://issues.apache.org/jira/browse/CB-12402 - Encode XML characters properly
+    var project_name_xml_esc = xmlescape(project_name);
+    shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r+'.xcworkspace',
'contents.xcworkspacedata'));
+    shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r+'.xcworkspace',
'xcshareddata', 'xcschemes', project_name +'.xcscheme'));
+
     var project_name_esc = project_name.replace(/&/g, '\\&');
     shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcodeproj', 'project.pbxproj'));
-    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcworkspace', 'contents.xcworkspacedata'));
-    shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcworkspace', 'xcshareddata',
'xcschemes', project_name +'.xcscheme'));
     shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
     shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
     shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.h'));
diff --git a/bin/templates/scripts/cordova/version b/bin/templates/scripts/cordova/version
index 9f3eb4799..e3d0fb4c4 100755
--- a/bin/templates/scripts/cordova/version
+++ b/bin/templates/scripts/cordova/version
@@ -26,7 +26,7 @@
 */
 
 // Coho updates this line
-var VERSION="4.3.1";
+var VERSION="4.3.2";
 
 module.exports.version = VERSION;
 
diff --git a/node_modules/xml-escape/LICENSE b/node_modules/xml-escape/LICENSE
new file mode 100644
index 000000000..bd261effa
--- /dev/null
+++ b/node_modules/xml-escape/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Michael Hernandez
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/xml-escape/README.md b/node_modules/xml-escape/README.md
new file mode 100644
index 000000000..5faf9f91a
--- /dev/null
+++ b/node_modules/xml-escape/README.md
@@ -0,0 +1,38 @@
+xml-escape
+==========
+
+Escape XML in javascript (NodeJS)
+
+npm install xml-escape
+
+```javascript
+// Warning escape is a reserved word, so maybe best to use xmlescape for var name
+var xmlescape = require('xml-escape');
+
+xmlescape('"hello" \'world\' & false < true > -1');
+
+// output
+// '&quot;hello&quot; &apos;world&apos; &amp; false &lt; true &gt;
-1'
+
+// don't escape some characters
+xmlescape('"hello" \'world\' & false < true > -1', '>"&')
+
+// output
+// '"hello" &apos;world&apos; & false &lt; true > -1'
+```
+
+
+There is also now an ignore function thanks to @jayflo
+
+```javascript
+esc = require('./');
+
+ignore = '"<&'
+// note you should never ignore an &
+output = esc('I am "<&not>" escaped', ignore)
+console.log(output)
+
+//I am "<&not&gt;" escaped
+```
+
+[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/miketheprogrammer/xml-escape/trend.png)](https://bitdeli.com/free
"Bitdeli Badge")
diff --git a/node_modules/xml-escape/index.js b/node_modules/xml-escape/index.js
new file mode 100644
index 000000000..8c37325ea
--- /dev/null
+++ b/node_modules/xml-escape/index.js
@@ -0,0 +1,22 @@
+
+
+var escape = module.exports = function escape(string, ignore) {
+  var pattern;
+
+  if (string === null || string === undefined) return;
+
+  ignore = (ignore || '').replace(/[^&"<>\']/g, '');
+  pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '');
+
+  return string.replace(new RegExp(pattern, 'g'), function(str, item) {
+            return escape.map[item];
+          })
+}
+
+var map = escape.map = {
+    '>': '&gt;'
+  , '<': '&lt;'
+  , "'": '&apos;'
+  , '"': '&quot;'
+  , '&': '&amp;'
+}
\ No newline at end of file
diff --git a/node_modules/xml-escape/package.json b/node_modules/xml-escape/package.json
new file mode 100644
index 000000000..51a5714e9
--- /dev/null
+++ b/node_modules/xml-escape/package.json
@@ -0,0 +1,91 @@
+{
+  "_args": [
+    [
+      {
+        "raw": "xml-escape@^1.1.0",
+        "scope": null,
+        "escapedName": "xml-escape",
+        "name": "xml-escape",
+        "rawSpec": "^1.1.0",
+        "spec": ">=1.1.0 <2.0.0",
+        "type": "range"
+      }
+    ]
+  ],
+  "_from": "xml-escape@>=1.1.0 <2.0.0",
+  "_id": "xml-escape@1.1.0",
+  "_inCache": true,
+  "_location": "/xml-escape",
+  "_nodeVersion": "5.5.0",
+  "_npmOperationalInternal": {
+    "host": "packages-13-west.internal.npmjs.com",
+    "tmp": "tmp/xml-escape-1.1.0.tgz_1457961063163_0.10634087934158742"
+  },
+  "_npmUser": {
+    "name": "mhernandez",
+    "email": "michael.hernandez1988@gmail.com"
+  },
+  "_npmVersion": "3.3.12",
+  "_phantomChildren": {},
+  "_requested": {
+    "raw": "xml-escape@^1.1.0",
+    "scope": null,
+    "escapedName": "xml-escape",
+    "name": "xml-escape",
+    "rawSpec": "^1.1.0",
+    "spec": ">=1.1.0 <2.0.0",
+    "type": "range"
+  },
+  "_requiredBy": [
+    "#USER",
+    "/"
+  ],
+  "_resolved": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.1.0.tgz",
+  "_shasum": "3904c143fa8eb3a0030ec646d2902a2f1b706c44",
+  "_shrinkwrap": null,
+  "_spec": "xml-escape@^1.1.0",
+  "author": {
+    "name": "Michael Hernandez - michael.hernandez1988@gmail.com"
+  },
+  "bugs": {
+    "url": "https://github.com/miketheprogrammer/xml-escape/issues"
+  },
+  "dependencies": {},
+  "description": "Escape XML ",
+  "devDependencies": {
+    "tape": "~2.4.2"
+  },
+  "directories": {},
+  "dist": {
+    "shasum": "3904c143fa8eb3a0030ec646d2902a2f1b706c44",
+    "tarball": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.1.0.tgz"
+  },
+  "gitHead": "c42a09afa81e645ca6881dbaf384d7f3c63735e4",
+  "homepage": "https://github.com/miketheprogrammer/xml-escape",
+  "keywords": [
+    "Escape",
+    "XML",
+    "Unesacpe",
+    "encoding",
+    "xml-escape"
+  ],
+  "license": "MIT License",
+  "main": "index.js",
+  "maintainers": [
+    {
+      "name": "mhernandez",
+      "email": "michael.hernandez1988@gmail.com"
+    }
+  ],
+  "name": "xml-escape",
+  "optionalDependencies": {},
+  "readme": "ERROR: No README data found!",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/miketheprogrammer/xml-escape.git"
+  },
+  "scripts": {
+    "test": "node test.js"
+  },
+  "version": "1.1.0"
+}
diff --git a/node_modules/xml-escape/test.js b/node_modules/xml-escape/test.js
new file mode 100644
index 000000000..21ad21896
--- /dev/null
+++ b/node_modules/xml-escape/test.js
@@ -0,0 +1,29 @@
+var test = require('tape');
+var escape = require('./index');
+test("Characters should be escaped properly", function (t) {
+    t.plan(1);
+
+    t.equals(escape('" \' < > &'), '&quot; &apos; &lt; &gt; &amp;');
+})
+
+test("Module should respect ignore string", function (t) {
+    t.plan(3);
+
+    t.equals(escape('" \' < > &', '"'), '" &apos; &lt; &gt; &amp;');
+    t.equals(escape('" \' < > &', '>&'), '&quot; &apos; &lt;
> &');
+    t.equals(escape('" \' < > &', '"\'<>&'), '" \' < > &');
+})
+
+test("Module should not escape random characters", function (t) {
+    t.plan(1);
+
+    t.equals(escape('<[whats up]>', '<]what'), '<[whats up]&gt;');
+})
+
+test("Module should not crash on null or undefined input", function (t) {
+    t.plan(3);
+
+    t.equals((escape("")), "");
+    t.doesNotThrow(function(){escape(null);}, TypeError);
+    t.doesNotThrow(function(){escape(undefined);}, TypeError);
+})
diff --git a/package.json b/package.json
index 3d8ce767a..3bd1c5533 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova-ios",
-  "version": "4.3.1",
+  "version": "4.3.2",
   "description": "cordova-ios release",
   "main": "bin/templates/scripts/cordova/Api.js",
   "repository": {
@@ -43,7 +43,8 @@
     "plist": "^1.2.0",
     "q": "^1.4.1",
     "shelljs": "^0.5.3",
-    "xcode": "^0.8.5"
+    "xcode": "^0.8.5",
+    "xml-escape": "^1.1.0"
   },
   "bundledDependencies": [
     "cordova-common",
@@ -52,6 +53,7 @@
     "plist",
     "q",
     "shelljs",
-    "xcode"
+    "xcode",
+    "xml-escape"
   ]
 }
diff --git a/tests/spec/create.spec.js b/tests/spec/create.spec.js
index 07a2bffc0..be6f48aec 100644
--- a/tests/spec/create.spec.js
+++ b/tests/spec/create.spec.js
@@ -102,6 +102,13 @@ describe('create', function() {
         createAndBuild(projectname, projectid);
     });
 
+    it('Test#008 : create project with ascii name, and spaces, ampersand(&)', function()
{
+       var projectname = 'hello & world';
+       var projectid = 'com.test.app7';
+
+       createAndBuild(projectname, projectid);
+    });
+
 });
 
 describe('end-to-end list validation', function(){


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Apps with ampersand (&) in the name throw build error in cordova-ios@4.3.1
> --------------------------------------------------------------------------
>
>                 Key: CB-13948
>                 URL: https://issues.apache.org/jira/browse/CB-13948
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-ios
>    Affects Versions: 4.3.1
>            Reporter: Ronaldo Zanoni
>            Assignee: Suraj Pindoria
>            Priority: Major
>
> Cordova apps with an ampersand in the name give a build error in cordova-ios 4.3.1:
> "xcodebuild: error: Unable to load workspace 'Tom & Jerry.xcworkspace'.
> Reason: Could not open workspace file at ~/git/Tom & Jerry/platforms/ios/Tom &
Jerry.xcworkspace/contents.xcworkspacedata"
> I found that the problem is with the .xcworkspace file. The ampersand doesn't get encoded
in the XML files that are generated.
> PR that created the problem: [https://github.com/apache/cordova-ios/pull/247]
> Reproduce:
> 1. run cordova create HelloCordova
> 2. edit config.xml <name> tag inside to "Tom & Jerry"
> 3. run cordova platform add ios@4.3.1
> 4. run cordova build ios 
> --> ERROR
> *NOTE*: This was fixed in the _cordova-ios 4.4.0_, but that version has removed the _IOS
8_ support and we need that support yet.
> So, the solution is merge the branch _origin/4.3.x_ with this pull request: [https://github.com/apache/cordova-ios/pull/288]
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message