blackberry / webworks-gui

GUI Tool for WebWorks 2.0
https://developer.blackberry.com/html5/
Apache License 2.0
3 stars 5 forks source link

config.xml corrupted by xml-mapping if there's a comment before or after <widget/> #223

Open jsoref opened 10 years ago

jsoref commented 10 years ago

This was reported by @tneil:

If you have a config.xml of the form:

<!-- this comment will result in xml-mapping corrupting the config file -->
<widget id="com.blackberry.will_be_broken" version="0.0.1" 
  xmlns="http://www.w3.org/ns/widgets" 
  xmlns:cdv="http://cordova.apache.org/ns/1.0" 
  xmlns:rim="http://www.blackberry.com/ns/widgets">
  <name>Will be Broken</name>
  <author>Your Name</author>
  <description>A sample WebWorks application</description>
  <content src="index.html"/>
  <preference name="AutoHideSplashScreen" value="true"/>
  <preference name="ChildBrowser" value="enable"/>
  <preference name="DiskCache" value="disable"/>
  <preference name="HideKeyboardFormAccessoryBar" value="disable"/>
  <preference name="Orientation" value="default"/>
  <preference name="PopupBlocker" value="disable"/>
  <preference name="WebSecurity" value="enable"/>
</widget>

And you load the project and then change the name to "Is broken", and click save, you will get the following:

<row>
  <!--this comment will result in xml-mapping corrupting the config file-->
  <widget id="com.blackberry.will_be_broken" version="0.0.1" 
    xmlns="http://www.w3.org/ns/widgets" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0" 
    xmlns:rim="http://www.blackberry.com/ns/widgets">
    <name>Is broken</name>
    <author>Your Name</author>
    <description>A sample WebWorks application</description>
    <content src="index.html"/>
    <preference name="AutoHideSplashScreen" value="true"/>
    <preference name="ChildBrowser" value="enable"/>
    <preference name="DiskCache" value="disable"/>
    <preference name="HideKeyboardFormAccessoryBar" value="disable"/>
    <preference name="Orientation" value="default"/>
    <preference name="PopupBlocker" value="disable"/>
    <preference name="WebSecurity" value="enable"/>
  </widget>
</row>

Technically, we need to do three things:

  1. Fix our code (either using/crutching/shimming xml-mapping or replacing it) so that it does corrupt future projects.
  2. Add code to detect <row> / </row> and correct it (by stripping them).
  3. Release note this. To fix a corrupted project, you need to: A. Remove the <row> / </row> pair B. Move any comment inside <widget>...</widget>
jsoref commented 10 years ago

(I thought I filed this earlier, but I can't find it.)