-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
There is an error in cssmgr.php:164 :
if (preg_match('/@media/',$CSSstr)) {
preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
for($i=0; $i<count($m[0]); $i++) {
if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
}
else {
$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/',' '.$m[2][$i].' ',$CSSstr);
}
}
}On large CSS files with complicated rules it may cause regexp limit when replacing by preg_replace:
exception 'yii\base\ErrorException' with message 'preg_replace(): Compilation failed: regular expression is too large at offset 70187' in .../vendor/kartik-v/mpdf/classes/cssmgr.php:164
... but (as far as I can see) there is no real need in preg_replace() in this place. We have exact text, matched by preg_match_all() and now we can use str_replace() (or mb_str_replace()) to clear it out.
P.S. I don't offer pull request because I can miss something
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels