From 159e52fd02a07779940c6a2eaee85a78db73af7f Mon Sep 17 00:00:00 2001 From: Lex de Willigen Date: Wed, 20 Jan 2021 19:30:36 +0100 Subject: [PATCH 1/3] Update regex --- src/PhpWord/TemplateProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index fa8d8e6580..3f5c179ba2 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -741,7 +741,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria $xmlBlock = null; $matches = array(); preg_match( - '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + '/()(.*?)()/is', $this->tempDocumentMainPart, $matches ); @@ -761,7 +761,7 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria if ($replace) { $this->tempDocumentMainPart = str_replace( - $matches[2] . $matches[3] . $matches[4], + $matches[1] . $matches[3] . $matches[4], implode('', $cloned), $this->tempDocumentMainPart ); From f44f9363115c96625d78bc91dbcc9f40b976a3d6 Mon Sep 17 00:00:00 2001 From: Lex de Willigen Date: Wed, 20 Jan 2021 19:36:28 +0100 Subject: [PATCH 2/3] Update replaceBlock method --- src/PhpWord/TemplateProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 3f5c179ba2..bc631d54f3 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -781,14 +781,14 @@ public function replaceBlock($blockname, $replacement) { $matches = array(); preg_match( - '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + '/()(.*?)()/is', $this->tempDocumentMainPart, $matches ); if (isset($matches[3])) { $this->tempDocumentMainPart = str_replace( - $matches[2] . $matches[3] . $matches[4], + $matches[1] . $matches[3] . $matches[4], $replacement, $this->tempDocumentMainPart ); From 527f50401f06a401d535e743e455c74c73c5a2be Mon Sep 17 00:00:00 2001 From: troosan Date: Fri, 5 Feb 2021 20:43:37 +0100 Subject: [PATCH 3/3] remove whitespace --- tests/PhpWord/Reader/Word2007/ElementTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWord/Reader/Word2007/ElementTest.php b/tests/PhpWord/Reader/Word2007/ElementTest.php index d5db6be826..08b72418ac 100644 --- a/tests/PhpWord/Reader/Word2007/ElementTest.php +++ b/tests/PhpWord/Reader/Word2007/ElementTest.php @@ -64,7 +64,7 @@ public function testReadAlternateContent() $text = $elements[0]; $this->assertEquals('Test node value', trim($text->getElement(0)->getText())); } - + /** * Test reading of textbreak */