Red Hat Bugzilla – Bug 744200
Lines starting with whitespaces in XML files lead to perl warnings
Last modified: 2016-05-31 21:42:31 EDT
Description of problem: XML files which have whitespaces as the first character in a line lead to warnings like this Unable to recognise encoding of this document at /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX/PurePerl/EncodingDetect.pm line 96, <$in> line 793 Version-Release number of selected component (if applicable): perl-XML-SAX-0.14-8 How reproducible: Always Steps to Reproduce: 1. Run the attached perl script (conversion.pl) on the attached input file (input.xml) on a RHEL5 machine Actual results: lots of Unable to recognise encoding of this document at /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX/PurePerl/EncodingDetect.pm line 96, <$in> line 793 warnings for multiple lines Expected results: no warnings Additional info:
Created attachment 526893 [details] perl script
Created attachment 526894 [details] input file for the script
Created attachment 526895 [details] upstream patch
Upstream fixed this issue in version 2.15 (available from <http://cpan.metacpan.org/authors/id/G/GR/GRANTM/>) by accepting XML document starting with white spaces and defaulting to implicit encoding. This effectively silent the warning. This is the 4-line patch attached by Marcela. Simple test case: $ perl -MXML::Simple -e 'XML::Simple::XMLin(q{ <f/>})'
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Cause Parsing a XML document starting with a white space. Consequence Warning `Unable to recognize encoding of this document' has been printed. Fix Encoding detection code has been changed to recognize XML document with leading white space as document without XML declaration and with default encoding. Result No warning is printed anymore as such documents are valid documents with encoding detection rules conforming to documents without XML declaration.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1446.html