1--TEST-- 2Test writing Element::$innerHTML on HTML documents 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = DOM\HTMLDocument::createEmpty(); 9$el = $dom->createElement('div'); 10$dom->appendChild($el); 11$el->innerHTML = '<p>foo</p>'; 12echo $dom->saveXML(), "\n"; 13$el->innerHTML = '</div>'; 14echo $dom->saveXML(), "\n"; 15$el->innerHTML = ''; 16echo $dom->saveXML(), "\n"; 17$el->innerHTML = '<div></div> <p></p>'; 18echo $dom->saveXML(), "\n"; 19$el->innerHTML = "invalid\xffutf-8"; 20echo $dom->saveXML(), "\n"; 21 22// Create a non-interned string that gets the UTF-8 validity flag added 23$str = str_repeat("my valid string", random_int(1, 1)); 24preg_match('/^.*$/u', $str); 25$el->innerHTML = $str; 26echo $dom->saveXML(), "\n"; 27 28$dom = DOM\HTMLDocument::createEmpty(); 29$el = $dom->createElement('style'); 30$dom->appendChild($el); 31$el->innerHTML = '<p>foo</p>'; 32echo $dom->saveXML(), "\n"; 33 34$dom = DOM\HTMLDocument::createEmpty(); 35$el = $dom->createElementNS('urn:a', 'style'); 36$dom->appendChild($el); 37$el->innerHTML = '<p>foo</p>'; 38echo $dom->saveXML(), "\n"; 39 40$dom = DOM\HTMLDocument::createEmpty(); 41$el = $dom->createElement('textarea'); 42$dom->appendChild($el); 43$el->innerHTML = "</textarea>\0-->"; 44echo $dom->saveXML(), "\n"; 45 46?> 47--EXPECT-- 48<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 49<div xmlns="http://www.w3.org/1999/xhtml"><p>foo</p></div> 50<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 51<div xmlns="http://www.w3.org/1999/xhtml"></div> 52<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 53<div xmlns="http://www.w3.org/1999/xhtml"></div> 54<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 55<div xmlns="http://www.w3.org/1999/xhtml"><div></div> <p></p></div> 56<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 57<div xmlns="http://www.w3.org/1999/xhtml">invalid�utf-8</div> 58<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 59<div xmlns="http://www.w3.org/1999/xhtml">my valid string</div> 60<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 61<style xmlns="http://www.w3.org/1999/xhtml"><p>foo</p></style> 62<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 63<style xmlns="urn:a"><p xmlns="">foo</p></style> 64<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 65<textarea xmlns="http://www.w3.org/1999/xhtml"></textarea>�--></textarea> 66