cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [50/50] [abbrv] cordova-common git commit: CB-12250 CB-12409 iOS: Fix bug with escaping properties from plist file
Date Tue, 06 Jun 2017 05:00:18 GMT
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-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/03471631
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/03471631
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/03471631

Branch: refs/heads/master
Commit: 034716314a47bc6d8491ca71eec769194bc2aa72
Parents: eda4935
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

----------------------------------------------------------------------
 spec/plist-helpers.spec.js | 42 +++++++++++++++++++++++++++++++++++++++++
 src/util/plist-helpers.js  |  4 ++--
 2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-common/blob/03471631/spec/plist-helpers.spec.js
----------------------------------------------------------------------
diff --git a/spec/plist-helpers.spec.js b/spec/plist-helpers.spec.js
new file mode 100644
index 0000000..7b8cdbc
--- /dev/null
+++ b/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-common/blob/03471631/src/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/src/util/plist-helpers.js b/src/util/plist-helpers.js
index 38eb31b..1222fa8 100644
--- a/src/util/plist-helpers.js
+++ b/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, '\\$&');
 }


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


Mime
View raw message