Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.5

Bug #14760 Bug in getDocTypeDeclaration()
Submitted: 2008-10-08 14:21 UTC
From: fpospisil Assigned: ashnazg
Status: Closed Package: XML_Util (version 1.2.0)
PHP Version: 4.3.10 OS: Debian GNU/Linux
Roadmaps: 1.2.1    
Subscription  


 [2008-10-08 14:21 UTC] fpospisil (Frantisek Pospisil)
Description: ------------ Wrong quoting in getDocTypeDeclaration() function. Linefeeds "\n" on line no. 341 are not interpreted. To fix it, simply change quoting: return sprintf("<!DOCTYPE %s%s [\n%s\n]>", $root, $ref, $internalDtd); Test script: --------------- // fragment from example.php print 'building DocType declaration with internal DTD:<br>'; print '<pre>'; print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0', '<!ELEMENT additionalInfo (#PCDATA)>')); print '</pre>'; Expected result: ---------------- <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0" [ <!ELEMENT additionalInfo (#PCDATA)> ]> Actual result: -------------- building DocType declaration with internal DTD: <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0" [\n<!ELEMENT additionalInfo (#PCDATA)>\n]>

Comments

 [2008-11-12 21:54 UTC] ashnazg (Chuck Burgess)
Confirmed this bug via the provided test case, on PHP 5.2.4 on Ubuntu Hardy.
 [2008-11-13 00:04 UTC] ashnazg (Chuck Burgess)
This fix works for me. Also, I see the exact test script as part of the test suite, but it was written to accept the "\n" characters. Committed fix to Util.php as well as fixed the unit test case.