Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/DocxMerge/Docx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down