Skip Menu |

This queue is for tickets about the String-Comments-Extract CPAN distribution.

Report information
The Basics
Id: 63787
Status: resolved
Priority: 0/
Queue: String-Comments-Extract

People
Owner: Nobody in particular
Requestors: DOUGDUDE [...] cpan.org
Cc:
AdminCc:

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



Subject: regex can cause 'unterminated quoted string literal' error
Please see https://rt.cpan.org/Public/Bug/Display.html?id=51008 as this affects your code as well.
On Thu Dec 09 17:06:35 2010, DOUGDUDE wrote: Show quoted text
> Please see https://rt.cpan.org/Public/Bug/Display.html?id=51008 as this > affects your code as well.
Thanks for the report, I'll take a look.
On Thu Dec 09 20:36:25 2010, ROKR wrote: Show quoted text
> On Thu Dec 09 17:06:35 2010, DOUGDUDE wrote:
> > Please see https://rt.cpan.org/Public/Bug/Display.html?id=51008 as this > > affects your code as well.
> > > Thanks for the report, I'll take a look.
FYI, I can't seem to trigger a failure: perl -MString::Comments::Extract::SlashStar -e 'print String::Comments::Extract::SlashStar->extract_comments(q{return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); // Hello, World })' Works fine. I also ran the extractor against the whole jquery.tablesorter.js and it worked without error.
Subject: Re: [rt.cpan.org #63787] regex can cause 'unterminated quoted string literal' error
Date: Fri, 10 Dec 2010 00:43:17 -0500
To: <bug-String-Comments-Extract [...] rt.cpan.org>
From: "Douglas Wilson" <doug [...] somethingdoug.com>
I ran into this error when I tried to use it on http://code.jquery.com/jquery-1.4.4.js I'm going to put together a test case for you. Show quoted text
-----Original Message----- From: Robert Krimen via RT Sent: Thursday, December 09, 2010 21:01 To: DOUGDUDE@cpan.org Subject: [rt.cpan.org #63787] regex can cause 'unterminated quoted string literal' error <URL: https://rt.cpan.org/Ticket/Display.html?id=63787 > On Thu Dec 09 20:36:25 2010, ROKR wrote:
> On Thu Dec 09 17:06:35 2010, DOUGDUDE wrote:
> > Please see https://rt.cpan.org/Public/Bug/Display.html?id=51008 as this > > affects your code as well.
> > > Thanks for the report, I'll take a look.
FYI, I can't seem to trigger a failure: perl -MString::Comments::Extract::SlashStar -e 'print String::Comments::Extract::SlashStar->extract_comments(q{return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); // Hello, World })' Works fine. I also ran the extractor against the whole jquery.tablesorter.js and it worked without error.
On Fri Dec 10 00:43:34 2010, doug@somethingdoug.com wrote: Show quoted text
> I ran into this error when I tried to use it on > http://code.jquery.com/jquery-1.4.4.js > > I'm going to put together a test case for you.
Okay, was able to trigger it with that file, thanks.
On Fri Dec 10 01:05:55 2010, ROKR wrote: Show quoted text
> On Fri Dec 10 00:43:34 2010, doug@somethingdoug.com wrote:
> > I ran into this error when I tried to use it on > > http://code.jquery.com/jquery-1.4.4.js > > > > I'm going to put together a test case for you.
> > Okay, was able to trigger it with that file, thanks.
Ok. It looks like the issue was slightly different from the one in that ticket; attached is a patch for a test file with the very minimal JS file that causes it. Looks like it is caused by a literal quote being inside a regular expression.
Subject: 0001-Add-test-for-RT-63787.patch
From 106504eea2270fc5fe5d806bf493e572e55a1234 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <dougwilson@live.com> Date: Fri, 10 Dec 2010 01:16:45 -0500 Subject: [PATCH] Add test for RT # 63787 --- t/20-rt63787.t | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) create mode 100644 t/20-rt63787.t diff --git a/t/20-rt63787.t b/t/20-rt63787.t new file mode 100644 index 0000000..16cbd28 --- /dev/null +++ b/t/20-rt63787.t @@ -0,0 +1,23 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +use Test::Most; + +plan tests => 2; + +use String::Comments::Extract; + +my $re_with_quote = <<'__JS__'; + var re = /"/; +__JS__ + +my @comments; + +lives_ok { @comments = String::Comments::Extract::JavaScript->collect($re_with_quote) } + 'Parse JavaScript with a quote in q regular expression'; + +ok(@comments == 0, 'No comments'); + +exit 0; -- 1.7.3
On Fri Dec 10 01:20:32 2010, DOUGDUDE wrote: Show quoted text
> On Fri Dec 10 01:05:55 2010, ROKR wrote:
> > On Fri Dec 10 00:43:34 2010, doug@somethingdoug.com wrote:
> > > I ran into this error when I tried to use it on > > > http://code.jquery.com/jquery-1.4.4.js > > > > > > I'm going to put together a test case for you.
> > > > Okay, was able to trigger it with that file, thanks.
> > Ok. It looks like the issue was slightly different from the one in that > ticket; attached is a patch for a test file with the very minimal JS > file that causes it. Looks like it is caused by a literal quote being > inside a regular expression.
Thanks, think I figured out the bug in the scanner. The fix is pretty hacky, but seems to work. All of the tests, yours, parsing jQuery, parsing jquery.tablesorter.js, pass fine. Here's a link to the repository with the fixes: http://xrl.us/bia3ps (Link to github.com)
Subject: Re: [rt.cpan.org #63787] regex can cause 'unterminated quoted string literal' error
Date: Fri, 10 Dec 2010 03:28:26 -0500
To: <bug-String-Comments-Extract [...] rt.cpan.org>
From: "Douglas Wilson" <doug [...] somethingdoug.com>
Thank you for the quick resolution; I believe this is solved now. Show quoted text
-----Original Message----- From: Robert Krimen via RT Sent: Friday, December 10, 2010 2:41 To: DOUGDUDE@cpan.org Subject: [rt.cpan.org #63787] regex can cause 'unterminated quoted string literal' error <URL: https://rt.cpan.org/Ticket/Display.html?id=63787 > On Fri Dec 10 01:20:32 2010, DOUGDUDE wrote:
> On Fri Dec 10 01:05:55 2010, ROKR wrote:
> > On Fri Dec 10 00:43:34 2010, doug@somethingdoug.com wrote:
> > > I ran into this error when I tried to use it on > > > http://code.jquery.com/jquery-1.4.4.js > > > > > > I'm going to put together a test case for you.
> > > > Okay, was able to trigger it with that file, thanks.
> > Ok. It looks like the issue was slightly different from the one in that > ticket; attached is a patch for a test file with the very minimal JS > file that causes it. Looks like it is caused by a literal quote being > inside a regular expression.
Thanks, think I figured out the bug in the scanner. The fix is pretty hacky, but seems to work. All of the tests, yours, parsing jQuery, parsing jquery.tablesorter.js, pass fine. Here's a link to the repository with the fixes: http://xrl.us/bia3ps (Link to github.com)
Fixed in 0.021, thanks