Skip Menu |
 

This queue is for tickets about the XML-XPath CPAN distribution.

Report information
The Basics
Id: 14957
Status: resolved
Priority: 0/
Queue: XML-XPath

People
Owner: MANWAR [...] cpan.org
Requestors: matthew [...] mjwilson.demon.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.13
Fixed in: 1.21



Subject: Substring functions broken
Download (untitled) / with headers
text/plain 431b
The functions substring, substring-before and substring-after don't seem to work correctly in XML::XPath 1.13, running on perl v5.8.0 on Solaris. These functions don't seem to be tested as part of the module. substring-before("1999/04/01","/") returns an empty string instead of '1999'. substring-after("1999/04/01","/") returns an empty string instead of '04/01'. substring("12345",2) returns an empty string instead of '2345'.
From: matthew [...] mjwilson.demon.co.uk
Download (untitled) / with headers
text/plain 603b
[guest - Thu Oct 6 04:56:05 2005]: Show quoted text
> The functions substring, substring-before and substring-after don't > seem to work correctly in XML::XPath 1.13, running on perl v5.8.0 on > Solaris. These functions don't seem to be tested as part of the > module. > > substring-before("1999/04/01","/") returns an empty string instead of > '1999'. > > substring-after("1999/04/01","/") returns an empty string instead of > '04/01'. > > substring("12345",2) returns an empty string instead of '2345'.
The attached patch seems to make things work. (Disclaimer: I've never tried to patch a Perl module before.)
Download Function.pm.diffs
application/octet-stream 2.7k

Message body not shown because it is not plain text.

From: matthew [...] mjwilson.demon.c.ouk
I've attached some tests which demonstrate the fault, and which get fixed by the above patch.
Download 31stringfunc.t
text/x-perl 1.7k
use Test; use Data::Dumper; BEGIN { plan tests => 26 } use XML::XPath; ok(1); my $xp = XML::XPath->new(ioref => *DATA); ok($xp); my $resultset; $resultset = $xp->find('concat("1","2","3"'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '123'); $resultset = $xp->find('starts-with("123","1"'); ok($resultset->isa('XML::XPath::Boolean')); ok($resultset->to_literal(), 'true'); $resultset = $xp->find('starts-with("123","23"'); ok($resultset->isa('XML::XPath::Boolean')); ok($resultset->to_literal(), 'false'); $resultset = $xp->find('contains("123","1"'); ok($resultset->isa('XML::XPath::Boolean')); ok($resultset->to_literal(), 'true'); $resultset = $xp->find('contains("123","4"'); ok($resultset->isa('XML::XPath::Boolean')); ok($resultset->to_literal(), 'false'); $resultset = $xp->find('substring-before("1999/04/01","/")'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '1999'); $resultset = $xp->find('substring-before("1999/04/01","?")'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, ''); $resultset = $xp->find('substring-after("1999/04/01","/")'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '04/01'); $resultset = $xp->find('substring-after("1999/04/01","19")'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '99/04/01'); $resultset = $xp->find('substring-after("1999/04/01","2")'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, ''); $resultset = $xp->find('substring("12345",2,3)'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '234'); $resultset = $xp->find('substring("12345",2)'); ok($resultset->isa('XML::XPath::Literal')); ok($resultset, '2345'); __DATA__ <AAA> <BBB/> <BBB/> <BBB/> <BBB/> <BBB/> <BBB/> <BBB/> <BBB/> <CCC/> <CCC/> <CCC/> </AAA>
Download (untitled) / with headers
text/plain 157b
Hi, Thanks for reporting the issue. There is a similar issue raised below: https://rt.cpan.org/Ticket/Display.html?id=30819 Best Regards, Mohammad S Anwar
Download (untitled) / with headers
text/plain 207b
Hi, XML::XPath has been patched and uploaded. I applied the supplied patch to the method contains(), substring_before() and substring_after(). Unit tests have added as well. Best Regards, Mohammad S Anwar


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.