Skip to content

Commit ca45d14

Browse files
authored
Merge pull request #1809 from juzser/dev-master
Update the regexp to avoid catastrophic backtracking
2 parents 5080139 + 6087305 commit ca45d14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria
798798
$xmlBlock = null;
799799
$matches = array();
800800
preg_match(
801-
'/(<\?xml.*)(<w:p\b.*>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p\b.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
801+
'/(.*((?s)<w:p\b(?:(?!<w:p\b).)*?\${' . $blockname . '}<\/w:.*?p>))(.*)((?s)<w:p\b(?:(?!<w:p\b).)[^$]*?\${\/' . $blockname . '}<\/w:.*?p>)/is',
802802
$this->tempDocumentMainPart,
803803
$matches
804804
);

0 commit comments

Comments
 (0)