diff --git a/src/DocxMerge/Docx.php b/src/DocxMerge/Docx.php index 8b7f2fd..90e0e05 100644 --- a/src/DocxMerge/Docx.php +++ b/src/DocxMerge/Docx.php @@ -172,7 +172,9 @@ public function findAndReplace( $key, $value ) { $this->findAndReplaceWithStyles($key, $value); return; } - + + $value = htmlspecialchars( $value ); + // Search/Replace in document $this->docxDocument = str_replace( $key, $value, $this->docxDocument ); // Search/Replace in footers and headers @@ -186,6 +188,8 @@ public function findAndReplaceFirst( $key, $value ) { if ( strpos( $this->docxDocument, $key ) === FALSE ) return; if ( strpos( $this->docxDocument, $key ) + strlen( $key ) === FALSE ) return; + $value = htmlspecialchars( $value ); + $leftPart = substr( $this->docxDocument, 0, strpos( $this->docxDocument, $key ) ); $rightPart = substr( $this->docxDocument, strpos( $this->docxDocument, $key ) + strlen( $key ) ); $this->docxDocument = $leftPart.$value.$rightPart;