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

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

dpogue closed pull request #45: CB-13496: Fix greedy regex in plist-helpers
URL: https://github.com/apache/cordova-common/pull/45
 
 
   

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/spec/plist-helpers.spec.js b/spec/plist-helpers.spec.js
index 3a6fa02..fc4c923 100644
--- a/spec/plist-helpers.spec.js
+++ b/spec/plist-helpers.spec.js
@@ -58,3 +58,35 @@ describe('prunePLIST', function () {
         done();
     });
 });
+
+describe('plistGraft', function () {
+    let doc = {
+        'keychain-access-groups': [
+            '$(AppIdentifierPrefix)io.cordova.hellocordova',
+            '$(AppIdentifierPrefix)com.example.mylib'
+        ]
+    };
+
+    let xml = '<array>' +
+                
'<string>$(AppIdentifierPrefix)io.cordova.hellocordova</string>' +
+                '<string>$(AppIdentifierPrefix)com.example.mylib</string>' +
+              '</array>';
+
+    let selector = 'keychain-access-groups';
+
+    it('Test 01: should not mangle existing plist entries', function (done) {
+        var graftStatus = plistHelpers.graftPLIST(doc, xml, selector);
+
+        expect(graftStatus).toBeTruthy();
+        expect(doc).toEqual(
+            {
+                'keychain-access-groups': [
+                    '$(AppIdentifierPrefix)io.cordova.hellocordova',
+                    '$(AppIdentifierPrefix)com.example.mylib'
+                ]
+            }
+        );
+
+        done();
+    });
+});
diff --git a/src/util/plist-helpers.js b/src/util/plist-helpers.js
index 5ec4c1d..0b4fdc1 100644
--- a/src/util/plist-helpers.js
+++ b/src/util/plist-helpers.js
@@ -80,7 +80,7 @@ function pruneOBJECT (doc, selector, fragment) {
 
 function nodeEqual (node1, node2) {
     if (typeof node1 !== typeof node2) { return false; } else if (typeof node1 
=== 'string') {
-        node2 = escapeRE(node2).replace(/\\\$\S+/gm, '(.*?)');
+        node2 = escapeRE(node2).replace(/\\\$\(\S+\)/gm, '(.*?)');
         return new RegExp('^' + node2 + '$').test(node1);
     } else {
         for (var key in node2) {


 

----------------------------------------------------------------
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:
[email protected]


> the plugin config-file tag for iOS plist array behaves unnaturally.
> -------------------------------------------------------------------
>
>                 Key: CB-13496
>                 URL: https://issues.apache.org/jira/browse/CB-13496
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-common
>    Affects Versions: 2.1.0
>         Environment: Mac OSX
>            Reporter: Ken Naito
>            Priority: Trivial
>   Original Estimate: 504h
>  Remaining Estimate: 504h
>
> In the src/util/plist-helpers.js, in the nodeEqual function,
> ```
> node2 = escapeRE(node2).replace(/\\\$\S+/gm, '(.*?)');
> ```
> seems the strange behavior.
> For example, the escaped node2 "$(ABC)Hello" becomes "(.*?)".
> In the previous version of this code is
> ```
> node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
> ```
> in this case, the escaped node2 "$(ABC)Hello" is unchaned.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to