Bug 744200 - Lines starting with whitespaces in XML files lead to perl warnings
Summary: Lines starting with whitespaces in XML files lead to perl warnings
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: perl-XML-SAX
Version: 5.7
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: rc
: 5.8
Assignee: Petr Pisar
QA Contact: Petr Šplíchal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-10-07 13:05 UTC by Marko Karg
Modified: 2018-11-14 10:16 UTC (History)
4 users (show)

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.
Clone Of:
Environment:
Last Closed: 2011-11-14 03:07:04 UTC
Target Upstream Version:


Attachments (Terms of Use)
perl script (6.53 KB, text/plain)
2011-10-07 13:06 UTC, Marko Karg
no flags Details
input file for the script (396.43 KB, text/xml)
2011-10-07 13:06 UTC, Marko Karg
no flags Details
upstream patch (609 bytes, patch)
2011-10-07 13:09 UTC, Marcela Mašláňová
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1446 0 normal SHIPPED_LIVE perl-XML-SAX bug fix update 2011-11-14 08:02:40 UTC

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


Note You need to log in before you can comment on or make changes to this bug.