Skip to content

Commit

Permalink
XML parser should ignore PerlIO layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jorol committed Apr 5, 2014
1 parent 857c365 commit bd65b9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/MAB2/Parser/XML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ sub new {
# check for file or filehandle
my $ishandle = eval { fileno($input); };
if ( !$@ && defined $ishandle ) {
binmode $input; # drop all PerlIO layers, as required by libxml2
my $reader = XML::LibXML::Reader->new( IO => $input )
or croak "cannot read from filehandle $input\n";
$self->{filename} = scalar $input;
$self->{xml_reader} = $reader;
}
elsif ( -e $input ) {
elsif ( defined $input && $input !~ /\n/ && -e $input ) {
my $reader = XML::LibXML::Reader->new( location => $input )
or croak "cannot read from file $input\n";
$self->{filename} = $input;
Expand Down

0 comments on commit bd65b9e

Please sign in to comment.