Doc #60747 [Opn->Csd]: DOMDocument loadHTML error with img close tag

From: Date: Fri, 13 Jan 2012 23:06:57 +0000
Subject: Doc #60747 [Opn->Csd]: DOMDocument loadHTML error with img close tag
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7779@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60747&edit=1 ID: 60747 Updated by: frozenfire@php.net Reported by: mattsnowboard at gmail dot com Summary: DOMDocument loadHTML error with img close tag -Status: Open +Status: Closed Type: Documentation Problem Package: DOM XML related PHP Version: 5.3.9 -Assigned To: +Assigned To: frozenfire Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. While the documentation makes no mention of the functions *not* producing errors for malformed HTML, it isn't clear that it does. I've made note of that. Previous Comments: ------------------------------------------------------------------------ [2012-01-13 23:05:09] frozenfire@php.net Automatic comment from SVN on behalf of frozenfire Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=322237 Log: Noted warnings produced by malformed HTML. Closes bug #60747. ------------------------------------------------------------------------ [2012-01-13 16:18:17] mattsnowboard at gmail dot com Description: ------------ --- From manual page: http://www.php.net/domdocument.loadhtml --- It says that this function should handle input that is not well-formed without error. However, I have tried to parse a page (that I don't have control over) and found it will throw errors. I have found that this can be avoided with: libxml_use_internal_errors(true). If I remove the first line of the example below, I just get an error page, which I wouldn't expect from reading the documentation. I feel that this should be more clear in the documentation, but I'm assuming it's not a bug by itself. Test script: --------------- <?php libxml_use_internal_errors(true); $document->loadHTML( '<img src="a.png" alt="a"></img>' ); foreach ( libxml_get_errors() as $error ) { var_dump( $error ); } $imgs = $document->getElementsByTagName( 'img' ); var_dump( $imgs ); ?> Expected result: ---------------- object(DOMNodeList)[3] Actual result: -------------- object(LibXMLError)[2] public 'level' => int 2 public 'code' => int 76 public 'column' => int 32 public 'message' => string 'Unexpected end tag : img ' (length=25) public 'file' => string '' (length=0) public 'line' => int 1 object(DOMNodeList)[3] ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60747&edit=1

« previous php.doc.bugs (#7779) next »