-
Notifications
You must be signed in to change notification settings - Fork 7
comment parser regexp is buggy #7
Comments
Could you please send through an example of both the code less you're trying to parse and the PHP code to do so. Ideally as a new unit test. Thanks. |
Hi,find the attached (or download from here http://nlacsoft.net/_test/test_comment.zip). It is the latest version of the less.php package, i added 1 new files:/test/test_comment.phpThe script tries to compile "reset.less" from your test cases. If i call this script from a browser running a local apache, i get a status "Aborted" and a message "The connection was reset". If i remove the comment or a part of the comment content from the beginning of the file, the compilation will be successful.I use WindowsXP SP3, latest EasyPHP with the default configuration, i tried on two machines also.RegardsLaszlo~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~From: nlacsoft@gmail.comDate: 6:18:09 AM, 11.28.2011Subject: Re: [less.php] comment parser regexp is buggy (#7)~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~>>Could you please send through an example of both the code less you're trying to parse and the PHP code to do so. Ideally as a new unit test. Thanks.>> >> --- >> Reply to this email directly or view it on GitHub:>> https://github.com/agar/less.php/issues/7#issuecomment-2892953>> |
I run your "test_comment.php" and it works ok. Try to read your apache error log for more informations why you get "Aborted" status. |
Hi, the apache error log contains nothing. The issue should be connected to this: http://stackoverflow.com/questions/7620910/regexp-in-preg-match-function-returning-browser-error I purified the case (find below) and setting pcre.recursion_limit=512 in php.ini i get no error any more but also get no match. //Simplified case for regex bug //comment from reset.less
//regexp from Parser.ph line 308 print_r($matches); |
Are you working on WIndows? On Linux is everything fine, but on WIndows it fails becouse of Apache is compiled with smaller stack size, and it crashes with stack overflow. Optimizing the regex helps. |
yes i work on Windows, good to know that on Linux Apache is compiled differently so, that explains the issue. I suggested the same regexp as you above, it implies much less recursion. |
Try this: Mordred/less.php@22efc1c |
Hello,
when a long css comment /* ... */ is being parsed, the match() method will fail and the http connection will also fail with status "Aborted". It is invoked in Parser::parseComment().
The right regexp for parsing css comments in php is eg.: #/*._?_/#Us
The text was updated successfully, but these errors were encountered: