[PEAR-BUG] Bug #16544 [Com]: HTML_CSS undefined index on malformed input

[email protected] ("tenitski")
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at http://pear.php.net/bugs/bug.php?id=16544&edit=1

 ID:               16544
 Comment by:       tenitski
 Reported By:      alexei at ten dot net dot nz
 Summary:          HTML_CSS undefined index on malformed input
 Status:           Open
 Type:             Bug
 Package:          HTML_CSS
 Operating System: Linux
 Package Version:  1.5.4
 PHP Version:      5.2.5
 New Comment:

Your fix does not help with this sort of input:

#contentholder{border-color:#C32327;}.title{color:#C32327;}

It recognizes only the first rule.


Previous Comments:
------------------------------------------------------------------------

[2009-08-21 14:57:38] brunobg

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].

------------------------------------------------------------------------


-- 
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16544&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.