1--TEST-- 2DOMElement->prefix with empty string creates bogus prefix 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = new DOMDocument; 9$dom->loadXML("<hello:container xmlns:conflict=\"urn:foo\" xmlns:hello=\"http://www.w3.org/1999/xhtml\"/>"); 10 11$container = $dom->documentElement; 12 13echo "--- Changing the prefix to an empty string ---\n"; 14 15$container->prefix = ""; 16echo $dom->saveXML(); 17 18echo "--- Changing the prefix to an empty C-style string ---\n"; 19 20$container->prefix = "\0foobar"; 21echo $dom->saveXML(); 22 23echo "--- Changing the prefix to \"hello\" ---\n"; 24 25$container->prefix = "hello"; 26echo $dom->saveXML(); 27 28echo "--- Changing the prefix to that of a conflicting namespace (\"conflict\") ---\n"; 29 30try { 31 $container->prefix = "conflict"; 32} catch (DOMException $e) { 33 echo $e->getMessage(), "\n"; 34} 35echo $dom->saveXML(); 36 37?> 38--EXPECT-- 39--- Changing the prefix to an empty string --- 40<?xml version="1.0"?> 41<container xmlns:conflict="urn:foo" xmlns:hello="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"/> 42--- Changing the prefix to an empty C-style string --- 43<?xml version="1.0"?> 44<container xmlns:conflict="urn:foo" xmlns:hello="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"/> 45--- Changing the prefix to "hello" --- 46<?xml version="1.0"?> 47<hello:container xmlns:conflict="urn:foo" xmlns:hello="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"/> 48--- Changing the prefix to that of a conflicting namespace ("conflict") --- 49Namespace Error 50<?xml version="1.0"?> 51<hello:container xmlns:conflict="urn:foo" xmlns:hello="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"/> 52