Req #73175 [NEW]: DOMDocument::saveHTML's void elements list is not updated

From: Date: Mon, 26 Sep 2016 09:42:45 +0000
Subject: Req #73175 [NEW]: DOMDocument::saveHTML's void elements list is not updated
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204272@lists.php.net to get a copy of this message
From: duhamelantoine1995 at gmail dot com Operating system: Debian 8 PHP version: 7.0.11 Package: DOM XML related Bug Type: Feature/Change Request Bug description:DOMDocument::saveHTML's void elements list is not updated Description: ------------ The DOMDocument::saveHTML and DOMDocument::saveHTMLFile methods does not product valid HTML when using void elements introduced in HTML5. The official HTML definition give a complete list of the void elements in HTML: https://www.w3.org/TR/html-markup/syntax.html#syntax-elements > The following is a complete list of the void elements in HTML: > > area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr In my tests (PHP 5&7, Debian 8 and Windows 10), PHP DOM render the following tags as non-void elements: - command - embed - keygen - source - track - wbr Test script: --------------- $implementation = new DOMImplementation; $dom = $implementation->createDocument( null, 'html', $implementation->createDocumentType('html', null, null) ); $dom->formatOutput = true; $body = $dom->createElement('body'); $div = $dom->createElement('div'); $dom->documentElement->appendChild($body); $body->appendChild($div); $voidElem = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',]; foreach ($voidElem as $tagName) { $div->appendChild($dom->createElement($tagName)); } echo $dom->saveHTML(); Expected result: ---------------- <!DOCTYPE html> <html><body><div> <area> <base> <br><col> <command><embed><hr> <img><input><keygen><link> <meta> <param> <source><track><wbr> </div></body></html> Actual result: -------------- <!DOCTYPE html> <html><body><div> <area> <base> <br><col> <command></command><embed></embed><hr> <img><input><keygen></keygen><link> <meta> <param> <source></source><track></track><wbr></wbr> </div></body></html> -- Edit bug report at https://bugs.php.net/bug.php?id=73175&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73175&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73175&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73175&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73175&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73175&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73175&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73175&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73175&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73175&r=support Expected behavior: https://bugs.php.net/fix.php?id=73175&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73175&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73175&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73175&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73175&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73175&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73175&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73175&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73175&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73175&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73175&r=mysqlcfg

« previous php.bugs (#204272) next »