Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.4

Bug #16544 HTML_CSS undefined index on malformed input
Submitted: 2009-08-21 18:57 UTC
From: brunobg Assigned:
Status: Open Package: HTML_CSS (version 1.5.4)
PHP Version: 5.2.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2009-08-21 18:57 UTC] brunobg (Bruno Barberi Gnecco)
Description: ------------ Malformed input generates an E_NOTICE exception with an undefined index. Can be easily fixed by adding one line (at line 2022 of version 1.5.4), marked with FIX below: $key = trim($keystr); if (!array_key_exists($key, $atRulesMap)) continue; // FIX $parentAtRule = isset($atRulesMap[$key][$i]) ? $atRulesMap[$key][$i] : $atRulesMap[$key][0]; Test script: --------------- $parsed = new HTML_CSS(); $parsed->parseString('function whatever() { do_this(); } '); Expected result: ---------------- No exception thrown. Actual result: -------------- Unknown error type: [8] Undefined index: Error in line 2023 of file /usr/lib/php/HTML/CSS.php The exception happens on access to $atRulesMap[$key].

Comments

 [2011-06-30 09:35 UTC] tenitski (Alexei Tenitski)
Your fix does not help with this sort of input: #contentholder{border-color:#C32327;}.title{color:#C32327;} It recognizes only the first rule.
 [2011-06-30 10:36 UTC] tenitski (Alexei Tenitski)
Looks like it does not support css with multiple rules on the same line eg following breaks it: $styles = array(' a {color: red;} p {color: green;} '); $css = new HTML_CSS(array('oneline' => true)); $css->parseData($styles); $css->parseData(array($css->toString())); Notice: Undefined index: p in Pear/HTML/CSS.php on line 2023