Skip to content

Commit 174f8ad

Browse files
author
Andrew Scott
committed
Fixes to the libxml2 work around for the additional encoding of src, href, action & name attributes when calling saveHTML() method.
1 parent fb71678 commit 174f8ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Document.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ public function saveHTML(?\DOMNode $node = null): string|false {
225225
$char = "'";
226226
}
227227

228-
$search[] = $newName. '=' . $char . $value . $char;
228+
// See xmlEscapeEntities() in:
229+
// https://github.com/GNOME/libxml2/blob/master/xmlsave.c
230+
$searchValue = str_replace(['<', '>', '&'], ['&lt;', '&gt;', '&amp;'], $value);
231+
232+
$search[] = $newName. '=' . $char . $searchValue . $char;
229233
$replace[] = $escape['attr']. '=' . $char . $value . $char;
230234

231235
$i++;

0 commit comments

Comments
 (0)