File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ public static function fromXML(DOMAttr $attr): static
106106 */
107107 public function toXML (DOMElement $ parent ): DOMElement
108108 {
109+ if ($ this ->getNamespaceURI () !== null && !$ parent ->lookupPrefix ($ this ->getNamespacePrefix ())) {
110+ $ parent ->setAttributeNS (
111+ 'http://www.w3.org/2000/xmlns/ ' ,
112+ 'xmlns: ' . $ this ->getNamespacePrefix (),
113+ $ this ->getNamespaceURI (),
114+ );
115+ }
116+
109117 $ parent ->setAttributeNS (
110118 $ this ->getNamespaceURI (),
111119 !in_array ($ this ->getNamespacePrefix (), ['' , null ])
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ final class DOMDocumentFactory
2424 * @var non-negative-int
2525 * TODO: Add LIBXML_NO_XXE to the defaults when PHP 8.4.0 + libxml 2.13.0 become generally available
2626 */
27- public const DEFAULT_OPTIONS = LIBXML_COMPACT | LIBXML_NONET ;
27+ public const DEFAULT_OPTIONS = LIBXML_COMPACT | LIBXML_NONET | LIBXML_NSCLEAN ;
2828
2929
3030 /**
You can’t perform that action at this time.
0 commit comments