cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cordova-lib git commit: CB-12250 CB-12409 iOS: Fix bug with escaping properties from plist file
Date Sat, 03 Jun 2017 00:38:22 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 1b1e7400c -> 64c1d61f4


CB-12250 CB-12409 iOS: Fix bug with escaping properties from plist file

 This closes #533


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/64c1d61f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/64c1d61f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/64c1d61f

Branch: refs/heads/master
Commit: 64c1d61f4b6b68151ced1630b20fe0831c1c3c3c
Parents: 1b1e740
Author: Nikita Matrosov <v-nimatr@microsoft.com>
Authored: Wed Mar 29 16:51:08 2017 +0300
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Fri Jun 2 17:36:39 2017 -0700

----------------------------------------------------------------------
 cordova-common/spec/plist-helpers.spec.js     | 42 ++++++++++++++++++++++
 cordova-common/src/util/plist-helpers.js      |  4 +--
 cordova-lib/src/plugman/util/plist-helpers.js |  4 +--
 3 files changed, 46 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/64c1d61f/cordova-common/spec/plist-helpers.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/plist-helpers.spec.js b/cordova-common/spec/plist-helpers.spec.js
new file mode 100644
index 0000000..7b8cdbc
--- /dev/null
+++ b/cordova-common/spec/plist-helpers.spec.js
@@ -0,0 +1,42 @@
+var plistHelpers = require('../src/util/plist-helpers');
+
+
+describe('prunePLIST', function() {
+    var doc =  {
+        FirstConfigKey: {
+            FirstPreferenceName: '*',
+            SecondPreferenceName: 'a + b',
+            ThirdPreferenceName: 'x-msauth-$(CFBundleIdentifier:rfc1034identifier)'
+        },
+
+        SecondConfigKey: {
+            FirstPreferenceName: 'abc'
+        }
+    };
+
+    var xml = '<dict>' +
+                '<key>FirstPreferenceName</key>' +
+                '<string>*</string>'  +
+                '<key>SecondPreferenceName</key>' +
+                '<string>a + b</string>'  +
+                '<key>ThirdPreferenceName</key>' +
+                '<string>x-msauth-$(CFBundleIdentifier:rfc1034identifier)</string>'
 +
+              '</dict>';
+
+    var selector = 'FirstConfigKey';
+
+    it('Test 01: should remove property from plist file using provided selector', function(done)
{
+        var pruneStatus = plistHelpers.prunePLIST(doc, xml, selector);
+
+        expect(pruneStatus).toBeTruthy();
+        expect(doc).toEqual(
+            {
+                SecondConfigKey: {
+                    FirstPreferenceName: 'abc'
+                }
+            }
+        );
+
+        done();
+    });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/64c1d61f/cordova-common/src/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/util/plist-helpers.js b/cordova-common/src/util/plist-helpers.js
index 38eb31b..1222fa8 100644
--- a/cordova-common/src/util/plist-helpers.js
+++ b/cordova-common/src/util/plist-helpers.js
@@ -84,7 +84,7 @@ function nodeEqual(node1, node2) {
     if (typeof node1 != typeof node2)
         return false;
     else if (typeof node1 == 'string') {
-        node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
+        node2 = escapeRE(node2).replace(/\\\$\S+/gm,'(.*?)');
         return new RegExp('^' + node2 + '$').test(node1);
     }
     else {
@@ -97,5 +97,5 @@ function nodeEqual(node1, node2) {
 
 // escape string for use in regex
 function escapeRE(str) {
-    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&');
+    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
 }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/64c1d61f/cordova-lib/src/plugman/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/plist-helpers.js b/cordova-lib/src/plugman/util/plist-helpers.js
index 2c60d4c..8d5384f 100644
--- a/cordova-lib/src/plugman/util/plist-helpers.js
+++ b/cordova-lib/src/plugman/util/plist-helpers.js
@@ -84,7 +84,7 @@ function nodeEqual(node1, node2) {
     if (typeof node1 != typeof node2)
         return false;
     else if (typeof node1 == 'string') {
-        node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
+        node2 = escapeRE(node2).replace(/\\\$\S+/gm,'(.*?)');
         return new RegExp('^' + node2 + '$').test(node1);
     }
     else {
@@ -97,5 +97,5 @@ function nodeEqual(node1, node2) {
 
 // escape string for use in regex
 function escapeRE(str) {
-    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&');
+    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
 }


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


Mime
View raw message