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 Mar 1, 2019
1 parent 3efecc6 commit fe276fa
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions CRM/Utils/PDF/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,20 @@ public static function html2pdf($text, $fileName = 'civicrm.pdf', $output = FALS
<div id=\"crm-container\">\n";

// Strip <html>, <header>, and <body> tags from each page

$htmlElementstoStrip = [
'@<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 = ['', '', '', '', '', ''];
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 fe276fa

Please sign in to comment.