Opened 13 years ago

Closed 12 years ago

#2381 closed defect (invalid)

ShrinkSafe Fails for simple Regular Expression Syntax

Reported by: Neill Jones Owned by: alex
Priority: high Milestone: 0.9
Component: BuildTools Version: 0.4.1
Keywords: shrinksafe Cc:
Blocked By: Blocking:

Description

Hello there,

I've just tried the rhino compression tool on some javascript code that I had already written and the compression complains about a syntax error that as far as I can see doesn't exist (and the code works perfectly well in Firefox and IE 6.0)

I've written a small test version of the code which still fails on my machine. Here it is

function test() {
	var lns = "id='abc'";
	var id = (lns.match(/id=['"]?([a-z0-9._/]*)/i))[1];
}

It fails saying ...

java -jar custom_rhino.jar -c compressionTest.js 

js: "compressionTest.js", line 3: missing ) after argument list
js:     var id = (lns.match(/id=['"]?([a-z0-9._/]*)/i))[1];
js: .........................................^
js: "compressionTest.js", line 1: Compilation produced 1 syntax errors.

but this is legit as far as I can tell. If you remove the . where it is complaining then in this case it will compile, but the . is allowed and on the main code it was actually complaining about the ='s not the . :-)

For example, with the line

  l.setAttribute('href', (lns[i].match(/href=['"]?([a-z0-9._/]*)/i))[1]);

It said

js: "libAJAX.js", line 369: missing ) after argument list
js:                     l.setAttribute('href', (lns[i].match(/href=['"]?([a-z0-9.\_/]*)/i))[1]);
js: .................................................................^
j

Any help appreciated, as without these problems I can get a 60% reduction which is well worth having :-)

This is on Rhino version "Rhino 1.6 release 4 2006 09 27" which I've just downloaded from the site.

Regards

Neill Jones

Change History (3)

comment:1 Changed 13 years ago by dylan

Milestone: 0.9

comment:2 Changed 12 years ago by Adam Peller

Keywords: shrinksafe added
Summary: Rhino Compression Fails for simple Regular Expression SyntaxShrinkSafe Fails for simple Regular Expression Syntax

comment:3 Changed 12 years ago by alex

Resolution: invalid
Status: newclosed

this is an issue in the Rhino parser itself and not in ShrinkSafe?, per sae. I suggest you file this in Mozilla's bugzilla since just running Rhino on the file also produces the parse error:

obelisk:/tmp alex$ cat tmp.js 
function test() {
        var lns = "id='abc'";
        var id = (lns.match(/id=['"]?([a-z0-9._/]*)/i))[1];
}
obelisk:/tmp alex$ rhino tmp.js 
js: "tmp.js", line 3: missing ) after argument list
js:     var id = (lns.match(/id=['"]?([a-z0-9._/]*)/i))[1];
js: .........................................^
js: "tmp.js", line 1: Compilation produced 1 syntax errors.
obelisk:/tmp alex$ 
Note: See TracTickets for help on using tickets.