Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 744200

Summary: Lines starting with whitespaces in XML files lead to perl warnings
Product: Red Hat Enterprise Linux 5 Reporter: Marko Karg <mkarg>
Component: perl-XML-SAXAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Petr Šplíchal <psplicha>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 5.7CC: ohudlick, ppisar, psabata, psplicha
Target Milestone: rcKeywords: EasyFix, Patch
Target Release: 5.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: perl-XML-SAX-0.14-11 Doc Type: Bug Fix
Doc Text:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-14 03:07:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
perl script
none
input file for the script
none
upstream patch none

Description Marko Karg 2011-10-07 13:05:47 UTC
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:

Comment 1 Marko Karg 2011-10-07 13:06:31 UTC
Created attachment 526893 [details]
perl script

Comment 2 Marko Karg 2011-10-07 13:06:58 UTC
Created attachment 526894 [details]
input file for the script

Comment 3 Marcela Mašláňová 2011-10-07 13:09:44 UTC
Created attachment 526895 [details]
upstream patch

Comment 5 Petr Pisar 2011-10-07 13:17:05 UTC
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/>})'

Comment 7 Petr Pisar 2011-10-10 10:58:43 UTC
    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.

Comment 10 errata-xmlrpc 2011-11-14 03:07:04 UTC
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