From:             
Operating system: Windows XP
PHP version:      5.3.2
Package:          DOM XML related
Bug Type:         Bug
Bug description: DOMDocument throws Unexpected end tag error when loading valid 
HTML

Description:
------------
I'm getting a php warning from DOMDocument after running a test script in
an 

attempt to load some html inside the DOM and then echo the html to the

browser:



Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end
tag

: strong in Entity, line: 8 in C:\www\dom-test.php on line 23



The problem is that DOMDocument::loadHTML() attempts to remove the

'</strong>'  tag from within a JavaScript string variable inside the

<script> tag. If I try to wrap <!-- --> around the content of the <script>

tag it will still throw the error.



I've tested it with php 5.2.0, 5.2.6, 5.2.11, 5.3 and 5.3.2. It

appears to work just fine in version 5.2.0 but the other version throw the

above error.



See Test script



Test script:
---------------
<?php

$html = '

<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"/>

        <script type="text/javascript">

            var html = "<strong>Bold Text</strong>,Normal Text";

            document.write(html);

            alert(html);

        </script>

    </head>

    <body> </body>

</html>';

$dom = new DOMDocument();

$dom->loadHTML($html);

echo $dom->saveHTML();

?>

Expected result:
----------------
Expected alert message from browser: 



<strong>Bold Text</strong>,Normal Text

Actual result:
--------------
Actual alert message from browser: 



<strong>Bold Text,Normal Text

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52012&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52012&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52012&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52012&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52012&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52012&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52012&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52012&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52012&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52012&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52012&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52012&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52012&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52012&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52012&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52012&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52012&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52012&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52012&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52012&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52012&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52012&r=mysqlcfg

Reply via email to