Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

JSMin-php gives error when parsing a specific string #10

Open
ghost opened this issue Dec 20, 2011 · 1 comment
Open

JSMin-php gives error when parsing a specific string #10

ghost opened this issue Dec 20, 2011 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 20, 2011

Hi,

We are currently experiencing problems with using JSMin. The javascript code that causes us problems is this:

var pattern=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;

The usage is this:
$jsmin_php = JSMin::minify(file_get_contents("error.js"));
echo $jsmin_php;

The error thrown is this:
Fatal error: Uncaught exception 'JSMinUnterminatedStringException' with message 'Unterminated String: ''+/=?^`{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:a-z0-9?.)+a-z0-9?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-][a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])+)])$/;'' in /home/kasper/kaspergrubbe.dk/htdocs/JSMin.php:151 Stack trace: #0 /home/kasper/kaspergrubbe.dk/htdocs/JSMin.php(123): JSMin->action(1) #1 /home/kasper/kaspergrubbe.dk/htdocs/JSMin.php(80): JSMin->min() #2 /home/kasper/kaspergrubbe.dk/htdocs/JSMin.php(53): JSMin::minify('var pattern=/^(...') #3 {main} thrown in /home/kasper/kaspergrubbe.dk/htdocs/JSMin.php on line 151

@jaydiablo
Copy link

I added your snippet as a test case in my fork of this project: https://github.com/jaydiablo/jsmin-php

It passes (which means that the output of the PHP version matches the output of the original C version).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant