Skip to content

Commit

Permalink
using mb_eregi_replace instead of preg_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
JO0st committed Dec 5, 2018
1 parent 354ee85 commit 9a048e2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions CRM/Utils/PDF/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,18 @@ public static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FAL

// Strip <html>, <header>, and <body> tags from each page
$htmlElementstoStrip = array(
'@<head[^>]*?>.*?</head>@siu',
'@<script[^>]*?>.*?</script>@siu',
'@<body>@siu',
'@</body>@siu',
'@<html[^>]*?>@siu',
'@</html>@siu',
'@<!DOCTYPE[^>]*?>@siu',
'<head[^>]*?>.*?</head>',
'<script[^>]*?>.*?</script>',
'<body>',
'</body>',
'<html[^>]*?>',
'</html>',
'<!DOCTYPE[^>]*?>',
);
$htmlElementsInstead = array('', '', '', '', '', '');
foreach ($pages as & $page) {
$page = preg_replace($htmlElementstoStrip,
$htmlElementsInstead,
$page
);
foreach ($htmlElementstoStrip as $pattern){
$page = mb_eregi_replace($pattern, '', $page);
}
}
// Glue the pages together
$html .= implode("\n<div style=\"page-break-after: always\"></div>\n", $pages);
Expand Down

0 comments on commit 9a048e2

Please sign in to comment.