Bug #19361 [Fbk]: CSS tokenzier generates errors when PHP embedded in CSS file

From: Date: Wed, 11 Apr 2012 04:18:53 +0000
Subject: Bug #19361 [Fbk]: CSS tokenzier generates errors when PHP embedded in CSS file
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8550@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19361&edit=1 ID: 19361 Updated by: gsherwood@squiz.net Reported By: news_001 at washammwa dot de -Summary: Undefined index: bracket_closer in .../Tokenizers/CSS.php +Summary: CSS tokenzier generates errors when PHP embedded in CSS file Status: Feedback Type: Bug Package: PHP_CodeSniffer Operating System: debian squeez Package Version: 1.3.3 PHP Version: 5.3.3 Assigned To: squiz Roadmap Versions: New Comment: -Summary: Undefined index: bracket_closer in .../Tokenizers/CSS.php +Summary: CSS tokenzier generates errors when PHP embedded in CSS file Previous Comments: ------------------------------------------------------------------------ [2012-04-11 03:03:15] squiz I think I see the problem. When PHP tokenizes this string, it see the closing tag and then stops tokenizing the rest. It wont handle PHP embedded into a CSS or JS file, where it doesn't expect there to be any PHP tags. Even though I can't get the tokenizer errors, they look the same as the sniff errors, so I think fixing this will fix your main issue. ------------------------------------------------------------------------ [2012-04-11 02:56:39] squiz I cant get any tokenizer errors to be reported, but I get a errors from the sniffs, which I will look at. I don't know if they will fix the issue you have reported or not. Does the formatting of the CSS file look correct in your comment? Can you paste that single line onto line 2 of a blank CSS file and have PHPCS generate errors or is there more in the file? ------------------------------------------------------------------------ [2012-04-04 10:00:41] christianweiss li {} should be in second line. first line is empty ------------------------------------------------------------------------ [2012-04-04 09:46:26] christianweiss CSS file is: li { background:url(<?php print $staticserver; ?>images/bullet.gif) left 1px no-repeat; margin:0px; padding-left:10px; margin-bottom:5px; line-height:13px;} I know it is not usual to have css files to be executed by php but your tokenizer should be robust enought. csslint (http://csslint.net/about.html) has no trouble to tokenize it. A sniff that warns that this type of dynamic css smells should be available. ------------------------------------------------------------------------ [2012-03-30 22:46:36] squiz -Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz Do you happen to have the CSS file that PHPCS was running on when the error occurred? I wont be able to fix this with just a backtrace because the order of tokens is really important for this. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://pear.php.net/bugs/bug.php?id=19361 -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19361&edit=1

« previous php.pear.bugs (#8550) next »