Skip Menu |

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

Report information
The Basics
Id: 125324
Status: open
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: chrispitude [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.52
Fixed in: (no value)



Subject: 'or' inside string() regex incorrectly matches everything
When the word "or" exists inside a handler's string regex, it causes the regular expression to always evaluate to true. In the attached code, I expect only the "Important:" line to be printed, but the "or" in "Important:" causes every <p> tag to match. The surrounding content in the regex doesn't seem to matter, nor the content of the strings being matched.
Subject: test.pl
#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $xhtml = <<EOF; <?xml version="1.0" encoding="UTF-8"?> <html><body> <h1><a name="CIHEHEAF"></a>Inserting Test Points</h1> <p>line1</p> <p>line2</p> <p>Important</p> <p>line3</p> <p>line4</p> </body></html> EOF my $twig=XML::Twig->new ( twig_handlers => { 'p[string()=~/^Impor/]' => \&p_note, } ); $twig->parse($xhtml); sub p_note { print "NOTE:".$_->sprint."\n"; }
On Wed May 16 11:49:12 2018, chrispitude@gmail.com wrote: Show quoted text
> When the word "or" exists inside a handler's string regex, it causes > the regular expression to always evaluate to true. > > In the attached code, I expect only the "Important:" line to be > printed, but the "or" in "Important:" causes every <p> tag to match. > > The surrounding content in the regex doesn't seem to matter, nor the > content of the strings being matched.
Duh! I have a version that fixes the problem, let me write the tests and I will upload it to the development site. __ mirod
Subject: Re: [rt.cpan.org #125324] 'or' inside string() regex incorrectly matches everything
Date: Sat, 19 May 2018 07:17:29 -0400
To: bug-XML-Twig [...] rt.cpan.org
From: Chris Papademetrious <chrispitude [...] gmail.com>
Will keep an eye out for it, but no hurry. Thanks!! - Chris On Thu, May 17, 2018 at 1:32 PM, MIROD via RT <bug-XML-Twig@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125324 > > > On Wed May 16 11:49:12 2018, chrispitude@gmail.com wrote:
> > When the word "or" exists inside a handler's string regex, it causes > > the regular expression to always evaluate to true. > > > > In the attached code, I expect only the "Important:" line to be > > printed, but the "or" in "Important:" causes every <p> tag to match. > > > > The surrounding content in the regex doesn't seem to matter, nor the > > content of the strings being matched.
> > Duh! > > I have a version that fixes the problem, let me write the tests and I will > upload it to the development site. > > __ > mirod >