Skip to content

Commit

Permalink
Performance improvement for #513.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Syroeshko committed Jun 2, 2015
1 parent 7fdc50b commit 1cd4fbf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/PhpWord/TemplateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ protected function fixBrokenMacros($documentPart)
{
$fixedDocumentPart = $documentPart;

$pattern = '|\$\{([^\}]+)\}|U';
preg_match_all($pattern, $fixedDocumentPart, $matches);
foreach ($matches[0] as $value) {
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
$fixedDocumentPart = str_replace($value, $valueCleaned, $fixedDocumentPart);
}
$fixedDocumentPart = preg_replace_callback(
'|\$\{([^\}]+)\}|U',
function ($match) {
return strip_tags($match[0]);
},
$fixedDocumentPart
);

return $fixedDocumentPart;
}
Expand Down

0 comments on commit 1cd4fbf

Please sign in to comment.