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-12844) Escape backslashes when creating a PBXShellScriptBuildPhase
Date Thu, 07 Dec 2017 09:06:00 GMT

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

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

SPLUMEJI commented on a change in pull request #2: CB-12844 Update pbxProject.js
URL: https://github.com/apache/cordova-node-xcode/pull/2#discussion_r155463225
 
 

 ##########
 File path: lib/pbxProject.js
 ##########
 @@ -1546,7 +1546,7 @@ function pbxShellScriptBuildPhaseObj(obj, options, phaseName) {
     obj.inputPaths = options.inputPaths || [];
     obj.outputPaths = options.outputPaths || [];
     obj.shellPath = options.shellPath;
-    obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"';
+    obj.shellScript = '"' + options.shellScript.replace(/\\/g, '\\\\') + '"';
 
 Review comment:
   https://github.com/apache/cordova-node-xcode/commit/3d5657ef3bbd5dd281def559fd85cee667637b9b#diff-35bc421794193e73d972308b4f2f3598

----------------------------------------------------------------
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


> Escape backslashes when creating a PBXShellScriptBuildPhase
> -----------------------------------------------------------
>
>                 Key: CB-12844
>                 URL: https://issues.apache.org/jira/browse/CB-12844
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-node-xcode
>    Affects Versions: 7.0.0, 6.4.0, 6.5.0
>         Environment: MacOS 10.12.4
> Xcode 8.3.2 (8E2002)
> Cordova 6.5.0
> node-xcode 0.9.0
>            Reporter: Nicholas Rawlings
>            Assignee: Anis Kadri
>            Priority: Minor
>
> Hooks can use the `node-xcode` package, which was contributed to the Cordova project
about a month ago, to modify an Xcode project.  When using `pbxProject.addBuildPhase()` to
add a new "Run Script" phase, backslashes in the passed script are not properly escaped. 
Unescaped backslashes can break the expected behavior of the shell script and result in a
malformed *.pbxproj file.
> The solution should be as simple as modifying the `pbxShellScriptBuildPhaseObj()` function
to replace unescaped backslashes  with escaped ones in the same way that double quote characters
are handled:
> ```javascript
> function pbxShellScriptBuildPhaseObj(obj, options, phaseName) {
>     obj.name = '"' + phaseName + '"';
>     obj.inputPaths = options.inputPaths || [];
>     obj.outputPaths = options.outputPaths || [];
>     obj.shellPath = options.shellPath;
>     obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"').replace(/\\/g, '\\\\')
+ '"';
>     return obj;
> }
> ```



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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


Mime
View raw message