I'm developing a CSS parser, but when it arrives in a block like this:
height: 100%;
background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
display: block;
First I have to normalize with:
$rules = str_replace(array("\n","\r"), array('',''), $rules);
// Que me retorna:
// height: 100%; background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); display: block;
(since files may come with rules on the same line)
And when applying:
$rules = explode(';',$rules);
Explode break in ;
within string "... gif ;
base64 ..."
I was able to "solve" by applying str_replace from ;base64
to -base64
and then at the time of rendering css, replacing -base64
with ;base64
. Gambiarra level 9000
This obviously limits to just this situation, and I need a broader solution, such as not breaking if ;
is within "
, '
, (
or )
I have tried str_getcsv
and it does not work ...
Pastebin full function.