estanglerbm opened a new issue #947:
URL: https://github.com/apache/royale-asjs/issues/947


   For XML text like this (i.e. e4x raw data during an HTTPService):
   
   <myxml><mynode red=\"value1\"\r\n green=\"value2\" blue=\"value3\" 
\r\nyellow=\"value4\" /></myxml>
   
   The XML object will remove "\r\n " or " \r\n", causing the attributes to be 
squished together, throwing a parsing error.
   
   The problem is trimXMLWhitespace():
   
   `            static private function trimXMLWhitespace(value:String):String
                {
                        return value.replace(/^\s+|\s+$/gm,'');
                }
   `
   
   The "^" and "$" are matching up with the literal newlines (\r\n).  Perhaps 
the original intent was to match just the beginning / end of the entire string.
   
   A quick workaround is to either return just "value" or replace with a single 
space instead of blank:
   
   `            static private function trimXMLWhitespace(value:String):String
                {
                        return value.replace(/^\s+|\s+$/gm,' ');
                }
   `
   
   I would imagine that CRLF embedded in actual text values are also getting 
stripped out unintentionally, but haven't tested that.
   
   Test case:
   
[TestXML.mxml.txt](https://github.com/apache/royale-asjs/files/5579860/TestXML.mxml.txt)
   
   Test exception:
   
   Uncaught Error: XML Parsing Error: not well-formed
   Location: file:///C:/src/royale-test-xml/bin/js-debug/index.html
   Line Number 1, Column 39:<sourcetext 
xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml";>&lt;parseRoot&gt;&lt;myxml&gt;&lt;mynode
 red="value1"green="value2" blue="value3"yellow="value4" 
/&gt;&lt;/myxml&gt;&lt;/parseRoot&gt;
   --------------------------------------^</sourcetext>
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to