xref: /PHP-5.6/ext/dom/tests/bug44648.phpt (revision 8d86597d)
1--TEST--
2Bug #44648 (Attribute names not checked for well formedness)
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$doc->loadXML('<root/>');
10
11$root = $doc->documentElement;
12
13try {
14  $attr = new DOMAttr('@acb', '123');
15  $root->setAttributeNode($attr);
16} catch (DOMException $e) {
17  echo $e->getMessage()."\n";
18}
19
20try {
21  $root->setAttribute('@def', '456');
22} catch (DOMException $e) {
23  echo $e->getMessage()."\n";
24}
25
26try {
27  $root->setAttributeNS(NULL, '@ghi', '789');
28} catch (DOMException $e) {
29  echo $e->getMessage()."\n";
30}
31
32try {
33  $root->setAttributeNS('urn::test', 'a:g@hi', '789');
34} catch (DOMException $e) {
35  echo $e->getMessage()."\n";
36}
37
38echo $doc->saveXML($root);
39?>
40--EXPECT--
41Invalid Character Error
42Invalid Character Error
43Invalid Character Error
44Namespace Error
45<root/>