Skip to content

[bug] Count the explode before the loop to avoid undefined index #2

@danyj

Description

@danyj

There is small bug here https://github.com/intekhabrizvi/cssparser/blob/master/Cssparser.php#L50

that triggers undefined index 1 if there are 2 selectors without properties next to each other like

$CssParser->read_from_string('.something{}.something{}');

suggested fix

$level2 = explode(";",trim($level1[2][$i]));

if(count($level2) > 1){
	
	foreach($level2 as $l2)
	{
		if(!empty($l2))
		{
			$level3 = explode(":", trim($l2));
			
			
			if(isset($level3[1])){
				$this->css[$this->clean($level1[1][$i])][$this->clean($level3[0])] = $this->clean($level3[1]);
				unset($level3);
			}
		}
	}
	unset($l2);
}
unset($level2);

I know that if they are empty the should not be included in CSS but in some dynamic prints it happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions