douglascrockford / JSMin

JavaScript Minification Filter
http://javascript.crockford.com/jsmin.html
695 stars 151 forks source link

JSMin gives error when parsing a specific string #4

Closed ghost closed 12 years ago

ghost commented 12 years ago

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

douglascrockford commented 12 years ago

Contact the author of jsmin.php.

On 12/20/2011 4:57 AM, Kasper 'kapöw' Grubbe wrote:

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


Reply to this email directly or view it on GitHub: https://github.com/douglascrockford/JSMin/issues/4

ghost commented 12 years ago

Sorry, wrong Github project, sorry. Moved here https://github.com/rgrove/jsmin-php/issues/10