Skip to content

Commit

Permalink
Fixes to the libxml2 work around for the additional encoding of src, …
Browse files Browse the repository at this point in the history
…href, action & name attributes when calling saveHTML() method.
  • Loading branch information
Andrew Scott committed Sep 27, 2023
1 parent fb71678 commit 174f8ad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ public function saveHTML(?\DOMNode $node = null): string|false {
$char = "'";
}

$search[] = $newName. '=' . $char . $value . $char;
// See xmlEscapeEntities() in:
// https://github.com/GNOME/libxml2/blob/master/xmlsave.c
$searchValue = str_replace(['<', '>', '&'], ['&lt;', '&gt;', '&amp;'], $value);

$search[] = $newName. '=' . $char . $searchValue . $char;
$replace[] = $escape['attr']. '=' . $char . $value . $char;

$i++;
Expand Down

0 comments on commit 174f8ad

Please sign in to comment.