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

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

dpogue closed pull request #20: CB-11691: Fix for modifying binary plists
URL: https://github.com/apache/cordova-common/pull/20
 
 
   

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/ConfigChanges/ConfigChanges.spec.js 
b/spec/ConfigChanges/ConfigChanges.spec.js
index 0e200ae..a0abe5c 100644
--- a/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/spec/ConfigChanges/ConfigChanges.spec.js
@@ -34,6 +34,7 @@ var editconfigplugin = path.join(__dirname, 
'../fixtures/plugins/org.test.editco
 var editconfigplugin_two = path.join(__dirname, 
'../fixtures/plugins/org.test.editconfigtest_two');
 var varplugin = path.join(__dirname, '../fixtures/plugins/com.adobe.vars');
 var plistplugin = path.join(__dirname, '../fixtures/plugins/org.apache.plist');
+var bplistplugin = path.join(__dirname, 
'../fixtures/plugins/org.apache.bplist');
 var android_two_project = path.join(__dirname, 
'../fixtures/projects/android_two/*');
 var android_two_no_perms_project = path.join(__dirname, 
'../fixtures/projects/android_two_no_perms', '*');
 var ios_config_xml = path.join(__dirname, 
'../fixtures/projects/ios-config-xml/*');
@@ -425,6 +426,19 @@ describe('config-changes module', function () {
                     expect(fs.readFileSync(path.join(temp, 'SampleApp', 
'SampleApp-Info.plist'), 
'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/);
                 });
             });
+            describe('of binary plist config files', function () {
+                it('should merge dictionaries and arrays, removing 
duplicates', function () {
+                    shell.cp('-rf', ios_config_xml, temp);
+                    shell.cp('-rf', bplistplugin, plugins_dir);
+                    var platformJson = PlatformJson.load(plugins_dir, 'ios');
+                    
platformJson.addInstalledPluginToPrepareQueue('org.apache.bplist', {});
+                    configChanges.process(plugins_dir, temp, 'ios', 
platformJson, pluginInfoProvider);
+                    var edited_plist = fs.readFileSync(path.join(temp, 
'SampleApp', 'SampleApp-binary.plist'), 'utf-8');
+                    
expect(edited_plist).toMatch(/<key>UINewsstandIcon<\/key>[\s\S]*<key>CFBundlePrimaryIcon<\/key>/);
+                    expect(fs.readFileSync(path.join(temp, 'SampleApp', 
'SampleApp-binary.plist'), 'utf-8')).toMatch(/<string>schema-b<\/string>/);
+                    expect(fs.readFileSync(path.join(temp, 'SampleApp', 
'SampleApp-binary.plist'), 
'utf-8')).not.toMatch(/(<string>schema-a<\/string>[^]*){2,}/);
+                });
+            });
             it('Test 025 : should resolve wildcard config-file targets to the 
project, if applicable', function () {
                 shell.cp('-rf', ios_config_xml, temp);
                 shell.cp('-rf', cbplugin, plugins_dir);
diff --git a/spec/fixtures/plugins/org.apache.bplist/plugin.xml 
b/spec/fixtures/plugins/org.apache.bplist/plugin.xml
new file mode 100644
index 0000000..ea6f1f9
--- /dev/null
+++ b/spec/fixtures/plugins/org.apache.bplist/plugin.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    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
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0";
+    xmlns:android="http://schemas.android.com/apk/res/android";
+    id="org.apache.bplist"
+    version="3.0.0">
+
+    <name>Binary PList updates</name>
+
+    <!-- ios -->
+    <platform name="ios">
+        <config-file target="*-binary.plist" parent="CFBundleIcons">
+            <dict>
+                <key>UINewsstandIcon</key>
+                <dict>
+                    <key>CFBundleIconFiles</key>
+                    <array>
+                        <string>Newsstand-Cover-Icon.png</string>
+                        <string>newsstand-cover-i...@2x.png</string>
+                    </array>
+                    <key>UINewsstandBindingType</key>
+                    <string>UINewsstandBindingTypeMagazine</string>
+                    <key>UINewsstandBindingEdge</key>
+                    <string>UINewsstandBindingEdgeLeft</string>
+                </dict>
+            </dict>
+        </config-file>
+
+        <config-file target="*-binary.plist" parent="CFValidSchemas">
+            <array>
+                <string>schema-a</string>
+                <string>schema-b</string>
+            </array>
+        </config-file>
+    </platform>
+</plugin>
diff --git 
a/spec/fixtures/projects/ios-config-xml/SampleApp/SampleApp-binary.plist 
b/spec/fixtures/projects/ios-config-xml/SampleApp/SampleApp-binary.plist
new file mode 100644
index 0000000..67a5811
Binary files /dev/null and 
b/spec/fixtures/projects/ios-config-xml/SampleApp/SampleApp-binary.plist differ
diff --git a/src/ConfigChanges/ConfigFile.js b/src/ConfigChanges/ConfigFile.js
index eb6df45..2e5ed5f 100644
--- a/src/ConfigChanges/ConfigFile.js
+++ b/src/ConfigChanges/ConfigFile.js
@@ -82,7 +82,7 @@ function ConfigFile_load () {
         //       Do we still need to support binary plist?
         //       If yes, use plist.parseStringSync() and read the file once.
         self.data = isBinaryPlist(filepath) ?
-            modules.bplist.parseBuffer(fs.readFileSync(filepath)) :
+            modules.bplist.parseBuffer(fs.readFileSync(filepath))[0] :
             modules.plist.parse(fs.readFileSync(filepath, 'utf8'));
     }
 }


 

----------------------------------------------------------------
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:
us...@infra.apache.org


> Plugin <config-file> can't modify binary plists
> -----------------------------------------------
>
>                 Key: CB-11691
>                 URL: https://issues.apache.org/jira/browse/CB-11691
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-common
>         Environment: Mac OS X version: 10.11.6
> Node version: v0.12.7
> Cordova version: 6.3.0
>            Reporter: Sky Kelsey
>            Priority: Major
>
> https://github.com/apache/cordova-lib/blob/master/cordova-common/src/util/plist-helpers.js#L27
> Cordova expects plists to be in XML format, and not binary. However, it fails 
> to apply changes silently, masking the problem. Can you please log failures 
> to modify config files, and ideally also add support for binary plists? All 
> plists are generated as binary in xcode projects by default, so anyone who 
> develops a plugin and needs to modify a plist is going to hit this issue.



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

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

Reply via email to