Package: libxml-feedpp-perl
Version: 0.34-1
Severity: normal
File: /usr/share/perl5/XML/FeedPP.pm
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
FeedPP auto-detects what the scalar passed to it means. It first checks
if it looks like an http[s] URL, then checks if it looks like XML, and
finally checks if its an existing file.
Unfortunately, the XML check looks for the <?xml ... ?> line, which, at
least by my reading of the XML spec, is not required. The attached patch
adds in a 'type' parameter to explicitly say what the scalar means:
XML::FeedPP->new($some_xml, type => 'string');
XML::FeedPP->new($some_url, type => 'url');
XML::FeedPP->new($some_file, type => 'file');
The patch isn't perfect; in particular:
- Even when the type is specified, auto-guessing is still done. But
it works good enough for my needs...
- I failed to update the documentation.
Because of these deficiancies, I have not set the 'patch' tag on the
bug.
- -- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable'), (130, 'unstable'), (120,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libxml-feedpp-perl depends on:
ii libxml-treepp-perl 0.33-1.1 XML::TreePP -- Pure Perl implement
ii perl 5.10.0-16 Larry Wall's Practical Extraction
libxml-feedpp-perl recommends no packages.
libxml-feedpp-perl suggests no packages.
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkkLoy4ACgkQ+z+IwlXqWf60qgCeKH452vO8RiYD/+OdsALBIGcG
Ne0An0RCpzjc43VL1nkkgI/pCp/wdc5j
=bm8m
-----END PGP SIGNATURE-----
--- FeedPP.pm.old 2008-10-23 23:24:07.000000000 -0400
+++ FeedPP.pm 2008-10-31 20:23:26.000000000 -0400
@@ -471,17 +471,19 @@
sub load {
my $self = shift;
my $source = shift;
+ my %args = @_;
+ my $method = $args{type} || '';
Carp::croak "No feed source" unless defined $source;
my $tree;
my $tpp = XML::TreePP->new(%$TREEPP_OPTIONS, @_);
- if ( $source =~ m#^https?://#s ) {
+ if ( $method =~ m#url#i || $source =~ m#^https?://#s ) {
$tree = $tpp->parsehttp( GET => $source );
}
- elsif ( $source =~ m#(^\s*)(<\?xml.*\?>|<\!DOCTYPE)#i ) {
+ elsif ( $method =~ m#string# || $source =~
m#(^\s*)(<\?xml.*\?>|<\!DOCTYPE)#i ) {
$tree = $tpp->parse($source);
}
- elsif ( $source !~ /[\r\n]/ && -f $source ) {
+ elsif ( $method =~ m#file# || $source !~ /[\r\n]/ && -f $source ) {
$tree = $tpp->parsefile($source);
}
Carp::croak "Invalid feed source: $source" unless ref $tree;