Bug #63477 [Com]: DOMDocument::loadHtml error in parsing attribute names

From: Date: Fri, 09 Nov 2012 22:34:26 +0000
Subject: Bug #63477 [Com]: DOMDocument::loadHtml error in parsing attribute names
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174610@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63477&edit=1 ID: 63477 Comment by: ryanve at gmail dot com Reported by: ryanve at gmail dot com Summary: DOMDocument::loadHtml error in parsing attribute names Status: Not a bug Type: Bug Package: DOM XML related Operating System: Linux PHP Version: 5.3.18 Block user comment: N Private report: N New Comment: @rasmus Thanks - I looked in phpinfo and the libxml version was 2.6.32 - I'll ask Dreamhost about upgrading. Previous Comments: ------------------------------------------------------------------------ [2012-11-09 22:18:29] rasmus@php.net This doesn't actually have much to do with PHP. This completely depends on whether the version of libxml2 you are using has support for this part of HTML5. I haven't looked into it, but I know there were HTML5 additions in libxml2 version 2.8.0. So in order to track this down, figure out which version of libxml2 you are using. Head over to http://xmlsoft.org/ and see if there is a more recent version that handles your case. If there isn't, open a feature request with them. If there is, ask Dreamhost to update their libxml2. ------------------------------------------------------------------------ [2012-11-09 22:08:24] ryanve at gmail dot com Description: ------------ HTML data attribute names can contain periods: <p data-1.5>This is valid in HTML5</p> DOMDocument::loadHtml does not properly parse the line above due to the period. It changes the 1.5 to 1 and/or throws an error: Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: error parsing attribute name in Entity Please see: http://www.w3.org/TR/html-markup/syntax.html#syntax-attributes http://stackoverflow.com/questions/13283699/sanitize-attribute-name I am using Dreamhost: PHP version: 5.3.13 (FastCGI) PHP build date: 2012-06-07 Test script: --------------- <?php # this throws an error: $dom = new DOMDocument; $dom->loadHtml('<a data-1.5="value"></a>'); echo $dom->saveHtml(); # this works fine: $dom = new DOMDocument; $a = $dom->createElement('a'); $a->setAttribute('data-1.5', 'value'); $dom->appendChild($a); echo $dom->saveHtml(); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63477&edit=1

« previous php.bugs (#174610) next »