Bug #63380 [Asn]: Allocation via libxml does not use PHP's per-request allocator
Edit report at https://bugs.php.net/bug.php?id=63380edit=1 ID: 63380 Updated by: rricha...@php.net Reported by:tstarl...@php.net Summary:Allocation via libxml does not use PHP's per-request allocator Status: Assigned Type: Bug Package:XML related Operating System: Linux PHP Version:master-Git-2012-10-29 (Git) -Assigned To:rrichards +Assigned To:tstarling Block user comment: N Private report: N New Comment: There is a major problem with doing this and why I didn't end tying into the PHP memory allocator. Depending upon setup, it is extremely likely to be able to hit memory corruption and/or mix memory allocations between modules. i.e. using mod_perl and mod_php will cause PHP to override the libxml memory handling functions (which are global) and bleed into mod_perl (or any others that are using libxml2) causing any number of results (crashes, security issues, etc..). The only way to be able to do something like this would be to make it compile time option which is disabled by default allowing those who know their environment intimately can utilize this at their own risk, Don't know if you want to write a patch for that or not. Otherwise I don't see any way this could safely be added, Previous Comments: [2012-10-29 21:55:03] tstarl...@php.net https://github.com/php/php-src/pull/223 [2012-10-29 03:25:17] tstarl...@php.net Description: Allocation via libxml does not use PHP's per-request allocator. So any memory used by libxml will not be accounted against memory_get_usage() or memory_limit. At Wikimedia we use libxml DOM trees to store wikitext parse trees, because they are more compact in memory than the equivalent pure-PHP data structures. When these parse trees are cached, the memory requirements can become excessive, and the memory is typically not returned to the system after request termination. Using xmlMemSetup() to set hook functions which use PHP's per-request allocation functions will allow us to more effectively monitor and limit the use of libxml in production. I've developed a patch and will submit it to GitHub as a pull request. Test script: --- $doc = new DOMDocument; for ( $i = 0; $i 100 ; $i++ ) { $doc-appendChild($doc-createElement('foo')); } print memory_get_usage().\n; Expected result: 312331440 (with debug and ZTS) Actual result: -- 694256 -- Edit this bug report at https://bugs.php.net/bug.php?id=63380edit=1
Bug #63015 [Asn-Csd]: Incorrect arginfo for DOMErrorHandler
Edit report at https://bugs.php.net/bug.php?id=63015edit=1 ID: 63015 Updated by: rricha...@php.net Reported by:Jared dot Williams1 at ntlworld dot com Summary:Incorrect arginfo for DOMErrorHandler -Status: Assigned +Status: Closed Type: Bug Package:DOM XML related Operating System: Irrelevant PHP Version:5.4.6 Assigned To:rrichards Block user comment: N Private report: N New Comment: The fix for this bug has been committed. 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. Previous Comments: [2012-09-20 06:38:45] rricha...@php.net Automatic comment on behalf of rrichards Revision: http://git.php.net/?p=php-src.git;a=commit;h=ffa72707c86750816f665656c02a0a0451300296 Log: fix bug #63015 (Incorrect arginfo for DOMErrorHandler) [2012-09-13 13:34:59] chr...@php.net Have to assign this to Rob, he's much better in this area than me [2012-09-05 14:18:41] larue...@php.net yes,, very likely, assign to the author :), chregu, could you confirm this? thanks [2012-09-05 13:52:29] Jared dot Williams1 at ntlworld dot com Description: Arg info for the DOMErrorHandler contains as class hint for DOMError http://lxr.php.net/xref/PHP_5_4/ext/dom/domerrorhandler.c#30 Which is undefined. I suspect it should mean DOMDomError ? -- Edit this bug report at https://bugs.php.net/bug.php?id=63015edit=1
Bug #55279 [Asn-Nab]: SimpleXml removes line breaks
Edit report at https://bugs.php.net/bug.php?id=55279edit=1 ID: 55279 Updated by: rricha...@php.net Reported by:mathieu at webberig dot be Summary:SimpleXml removes line breaks -Status: Assigned +Status: Not a bug Type: Bug Package:SimpleXML related Operating System: Windows PHP Version:5.3.6 Assigned To:rrichards Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Attribute values are normalized: http://www.w3.org/TR/REC-xml/#AVNormalize Previous Comments: [2011-07-25 06:27:06] paj...@php.net As http://www.w3.org/TR/REC-xml/#NT-AttValue says than new lines are valid in attribute values, it seems that almost no parser returns them. This is certainly a problem in libxml itself as simplexml does not transform the values returned by libxml. Assigne to Rob so he can check with the libxml devs, whether we like to change that or not :) [2011-07-25 06:17:55] mathieu at webberig dot be Description: SimpleXML seems to ignore/remove line breaks (\n) in the attributes. Line breaks inside an attribute are valid XML, but they're lost when you use SimpleXML to read the XML data. I encountered this problem when reading XML data provided by the Google Webmaster Tools API Test script: --- XML: ?xml version=1.0? feedentry description=this is the first line here's a second line and another! //feed PHP: $xml = simplexml_load_string($xmldata); foreach ($xml-entry as $entry) { $attributes = $entry-attributes(); print_r($attributes); } Expected result: Keep the line breaks from the attribute values after reading the string. $attributes['description'] == this is the first line here's a second line and another!; Actual result: -- The string no longer contains line breaks: $attributes['description'] == this is the first line here's a second line and another!; -- Edit this bug report at https://bugs.php.net/bug.php?id=55279edit=1
Req #44761 [Opn-Bgs]: DOM Large Files
Edit report at https://bugs.php.net/bug.php?id=44761edit=1 ID: 44761 Updated by: rricha...@php.net Reported by:xwisdom at yahoo dot com Summary:DOM Large Files -Status: Open +Status: Bogus Type: Feature/Change Request -Package:Feature/Change Request +Package:*General Issues Operating System: Windows XP PHP Version:5.2.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: [2011-10-14 15:27:16] clicky at erebot dot net The DOM extension is meant explicitely to handle small XML files as it requires a copy of the file being processed and a large number of objects be kept in memory (this is also true for the SimpleXML extension which is based on the same underlying parsing library). If you need a faster alternative, I'd suggest you take a look at the XMLReader and XML Parser extensions (http://php.net/manual/en/book.xmlreader.php and http://php.net/manual/en/book.xml.php, respectively). XMLReader works by using a cursor-based parsing approach, while XML Parser uses a push-based approach. Here are some drawbacks though when using these extensions: - validation may not be possible (true XML Parser) - you can't use XPath to browse through the data (true for both extensions) Hope this helps. [2008-04-17 14:34:45] xwisdom at yahoo dot com Description: I think the (X)HTML DOM features are great but I would like for it to process the DOMDocument much faster. It appears that the HTML DOM features in php are not able to handle large html files (200k+). It's slow down when processing these files. I would like to request that the DOM processing objects be given a speed boost. The DOM that's present in the browsers are much faster at processing the element. If this can be done then it would be great! -- Edit this bug report at https://bugs.php.net/bug.php?id=44761edit=1
Bug #60027 [Opn-Bgs]: DOMDocument::schemaValidate
Edit report at https://bugs.php.net/bug.php?id=60027edit=1 ID: 60027 Updated by: rricha...@php.net Reported by:richard at organicdata dot co dot za Summary:DOMDocument::schemaValidate -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: Centos 5.5 PHP Version:5.3.8 Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. issue in libxml not PHP Previous Comments: [2011-10-14 09:16:23] richard at organicdata dot co dot za I'm becoming very concerned at the apparent lack of positive interest in this issue from the PHP team. Even the risk of inability to validate one of the world's most used document formats should in my opinion be high on PHPs agenda - and if it indeed is a problem under xmllint then the PHP team should be pushing xmllint to sort it out - as ultimately it is PHP that benefits from the functionality. Just to give you some sense in our case - this functionality is critical and not being able to use it or get it fixed may be enough to stop our use of PHP - which I would be really sad to see happen as it is a great language in many regards. I am more than willing to help in any way I can with samples, testing and so on however I am unable to fix this on my own. I do need someone from the team to engage constructively. If someone could please engage I would really appreciate it. thanks [2011-10-13 06:49:56] richard at organicdata dot co dot za Hello I'm afraid the below isn't clear for me. Please can we keep this simple. All I need is either: 1. to be told how to upload the tiny XML file that has been requested by cataphract at php.net; or 2. for Felipe to confirm that he has received the XML file and for him to provide it to the appropriate person; as I have sent it to his email address felipe at php.net could someone please help here so this can move forward and hopefully be resolved as soon as possible. thank you [2011-10-11 22:22:17] fel...@php.net The bug tracker just allows the following mime-types: application/x-txt, text/plain, text/x-diff, text/x-patch, text/x-c++, text/x-c, text/x-m4 and cannot be larger than 100k. [2011-10-11 18:54:42] richard at organicdata dot co dot za hi i'm out of ideas - I htmlencoded the example xml file and submitted and I get this message ERROR: Please do not SPAM our bug system. please can someone help me with ideas as to how to submit the xml file requested thanks! [2011-10-11 18:36:23] richard at organicdata dot co dot za ah since I see the last comment immediately I can only assume that the site doesn't handle pasted xml comments. Is there any way I can upload the example file or is there some other preferred method of file submission? thanks again The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=60027 -- Edit this bug report at https://bugs.php.net/bug.php?id=60027edit=1
Bug #55766 [Opn-Bgs]: Incorrect xPath in children nodes
Edit report at https://bugs.php.net/bug.php?id=55766edit=1 ID: 55766 Updated by: rricha...@php.net Reported by:ekazakov at parallels dot com Summary:Incorrect xPath in children nodes -Status: Open +Status: Bogus Type: Bug Package:SimpleXML related Operating System: CentOS 5 PHP Version:5.3.8 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Fix your xpath expression not to search entire document Previous Comments: [2011-09-23 05:57:19] ekazakov at parallels dot com Description: For children nodes SimpleXMLElement::xpath searches the matching xPath in parent node. Workaround: Create new instances of SimpleXMLElement for each child. $xmlNode = new SimpleXMLElement($xmlNode-asXML()); Test script: --- $xmlData = XML foo bar afirst/a /bar bar asecond/a /bar /foo XML; $xmlObj = new SimpleXMLElement($xmlData); foreach ($xmlObj-children() as $xmlNode) { echo br . htmlspecialchars($xmlNode-asXML()) . br; var_dump($xmlNode-xpath(//a)); } Expected result: bar afirst/a /bar array(1) { [0]= object(SimpleXMLElement)#333 (1) { [0]= string(5) first } } bar asecond/a /bar array(1) { [0]= object(SimpleXMLElement)#333 (1) { [0]= string(6) second } } Actual result: -- bar afirst/a /bar array(2) { [0]= object(SimpleXMLElement)#333 (1) { [0]= string(5) first } [1]= object(SimpleXMLElement)#335 (1) { [0]= string(6) second } } bar asecond/a /bar array(2) { [0]= object(SimpleXMLElement)#331 (1) { [0]= string(5) first } [1]= object(SimpleXMLElement)#333 (1) { [0]= string(6) second } } -- Edit this bug report at https://bugs.php.net/bug.php?id=55766edit=1
Req #48587 [Asn-Csd]: MySQL PDO driver doesn't support SSL connections
Edit report at http://bugs.php.net/bug.php?id=48587edit=1 ID: 48587 Updated by: rricha...@php.net Reported by:michael dot stringer at yuuguu dot com Summary:MySQL PDO driver doesn't support SSL connections -Status: Assigned +Status: Closed Type: Feature/Change Request Package:PDO related Operating System: * PHP Version:* -Assigned To:mysql +Assigned To:rrichards 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2011-04-15 16:24:42] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=310239 Log: Implement FR #48587 (MySQL PDO driver doesn't support SSL connections) [2011-02-09 16:04:41] michael dot stringer at yuuguu dot com As of version 5.3.5 this still hasn't been implemented so it is not limited to 5.2.* [2011-02-09 15:51:10] and...@php.net 5.2.* only? If yes, then this will be won't fix. [2010-10-28 09:46:22] u...@php.net 5.2 is closed, http://www.php.net/archive/2010.php#id2010-07-22-1 The PHP development team would like to announce the immediate availability of PHP 5.2.14. This release focuses on improving the stability of the PHP 5.2.x branch with over 60 bug fixes, some of which are security related. This release marks the end of the active support for PHP 5.2. Following this release the PHP 5.2 series will receive no further active bug maintenance. Security fixes for PHP 5.2 might be published on a case by cases basis. All users of PHP 5.2 are encouraged to upgrade to PHP 5.3 [2009-06-17 15:55:44] michael dot stringer at yuuguu dot com Description: The mysqli driver supports connecting to MySQL databases using SSL certificates via the ssl_set command (which in turn calls the native client ssl_set function). Please add this functionality to the PDO driver. This is currently preventing us from switching from the mysqli APIs to PDO. -- Edit this bug report at http://bugs.php.net/bug.php?id=48587edit=1
Bug #54138 [Opn-Bgs]: DOMNode::getLineNo() doesn't return line number higher than 65535
Edit report at http://bugs.php.net/bug.php?id=54138edit=1 ID: 54138 Updated by: rricha...@php.net Reported by:dmitrij at stepanov dot lv Summary:DOMNode::getLineNo() doesn't return line number higher than 65535 -Status: Open +Status: Bogus Type: Bug Package:XML Reader Operating System: Windows 7 PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Known limitation of libxml2 Previous Comments: [2011-03-02 15:23:44] dmitrij at stepanov dot lv Description: DOMNode::getLineNo() doesn't return line number higher than 65535. I assume that unsigned short is used for file line enumeration either in XMLReader or DOMNode internals. Test script: --- Try reading with XMLReader an XML file that has more than 65535 lines. Then, when line nr. 65535 is reached, call XMLReader::expand()-getLineNo(). Expected result: Correct line number. Actual result: -- 65535 for lines, higher than 65525. -- Edit this bug report at http://bugs.php.net/bug.php?id=54138edit=1
Bug #54120 [Opn-Bgs]: Impossible to freed memory complety after call to Xpath() method.
Edit report at http://bugs.php.net/bug.php?id=54120edit=1 ID: 54120 Updated by: rricha...@php.net Reported by:ikaos at gmx dot fr Summary:Impossible to freed memory complety after call to Xpath() method. -Status: Open +Status: Bogus Type: Bug Package:SimpleXML related Operating System: Linux CentOS 5.5 x86_64 PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Memory is freed. http://xmlsoft.org/xmlmem.html you can read how memory is managed and might not be returned immediately to the kernel. Previous Comments: [2011-02-28 15:58:00] ikaos at gmx dot fr Description: --- From manual page: http://www.php.net/simplexmlelement.xpath --- Test script: --- ?php $sxe = NULL; $nodes = NULL; print(Without call to xpath method : . PHP_EOL); print(Memory before SXE : . memory_get_usage() . PHP_EOL); $sxe = new SimpleXMLElement(large_file.xml, 0, TRUE); $sxe = NULL; $nodes = NULL; print(Memory after freed memory : . memory_get_usage() . PHP_EOL . PHP_EOL); $sxe = NULL; $nodes = NULL; print(Calling xpath method : . PHP_EOL); print(Memory before SXE : . memory_get_usage() . PHP_EOL); $sxe = new SimpleXMLElement(large_file.xml, 0, TRUE); $nodes = $sxe-xpath('/ITEMS/ITEM'); $sxe = NULL; $nodes = NULL; print(Memory after freed memory : . memory_get_usage() . PHP_EOL . PHP_EOL); // short sleep, time to launch 'ps aux' sleep(10); ? Expected result: When I unset (or set to NULL) the result of the Xpath() method ($nodes in the example), I expect memory will be completly freed. It's not the case. I tried, to recursively unset each element from $nodes and I got the same result. Actual result: -- Result of the test script : Without call to xpath method : Memory before SXE : 625736 Memory after freed memory : 625904 Calling xpath method : Memory before SXE : 625904 Memory after freed memory : 1608944 memory_get_usage says that few kilos octets of memory are still used, but in reality several thousand mega octets are still used. # ps aux | grep test.php me 28859 83.4 48.3 *1119908* *996056* pts/3 S+ 15:30 0:08 /bin/php test.php -- Edit this bug report at http://bugs.php.net/bug.php?id=54120edit=1
Bug #53726 [Opn-Fbk]: importnode (deep) - nodes named as link
Edit report at http://bugs.php.net/bug.php?id=53726edit=1 ID: 53726 Updated by: rricha...@php.net Reported by:somiara at hotmail dot com Summary:importnode (deep) - nodes named as link -Status: Open +Status: Feedback Type: Bug Package:DOM XML related Operating System: Windows NT 6.1 build 7 PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. The example script while works fine for me is not the same as what you have for output nor what you expect. Can you provide a complete script with the actual output you are getting and where the error is? Previous Comments: [2011-01-12 16:49:28] somiara at hotmail dot com Description: import of nodes named as link kills trailing-slashs/-tags? Test script: --- $xml = new DOMDocument; $xml_dir = $xml-createElement(item); $pagedoc = new DOMDocument; $pagedoc-load($broadcaster.'test.xml'); $xml_page = $xml-createElement(page); $xml_page = $xml-importNode($pagedoc-documentElement, true); $xml_dir-appendChild($xml_page); $xml-appendChild($xml_dir); ## file 1 root subs route dispatch=root:abc / route disptach=root:defdef/route /subs /root file 2 root subs link dispatch=root:abc / link disptach=root:defdef/link /subs /root Expected result: ## - file 1 mainstage item root subs route dispatch=root:abc/ route disptach=root:defdef/route /subs /root /item /mainstage ## - file 2 mainstage item root subs link dispatch=root:abc/ link disptach=root:defdef/link /subs /root /item /mainstage Actual result: -- ## - file 1 mainstage item root subs route dispatch=root:abc/ route disptach=root:defdef/route /subs /root /item /mainstage ## - file 2 mainstage item root subs link dispatch=root:abc link disptach=root:def /subs /root /item /mainstage -- Edit this bug report at http://bugs.php.net/bug.php?id=53726edit=1
Req #50973 [Asn-Dup]: DOMDocument::saveHTML() should be able to take a node as an arg
Edit report at http://bugs.php.net/bug.php?id=50973edit=1 ID: 50973 Updated by: rricha...@php.net Reported by:geoffers+phpbugs at gmail dot com Summary:DOMDocument::saveHTML() should be able to take a node as an arg -Status: Assigned +Status: Duplicate Type: Feature/Change Request Package:DOM XML related Operating System: * PHP Version:5.*, 6 Assigned To:rrichards Block user comment: N Private report: N New Comment: dupe of bug #39771 which was already taken care of Previous Comments: [2010-11-28 11:58:09] valid at example dot com When this gets fixed, it should also fix http://bugs.php.net/bug.php?id=39771 [2010-03-05 22:06:34] paj...@php.net Rob, what's your opinion on this patch? [2010-02-10 18:25:44] geoffers+phpbugs at gmail dot com http://pastebin.ca/1792855 is a patch for this, based upon saveXML(). There is one notable difference between what I have, based on that, and what is currently there: the if (mem) within the if (!size) is not present within saveXML(), and nor as a result in my patch. I presume that it should either be in both saveXML and saveHTML or neither: any idea? And, of course, my prior comment was wrong: it's only saveXML() which has the argument, not save(). [2010-02-09 16:00:06] geoffers+phpbugs at gmail dot com Description: At the moment DOMDocument::save() and DOMDocument::saveXML() both take an optional first argument which is a node to serialize; DOMDocument::saveHTML() and DOMDocument::saveHTMLFile() have no such option and always serialize the whole file. For cases where HTML serialization is needed of a specific node, all that can be done is doing it within PHP code (which is comparatively very slow). As libxml includes the needed APIs to do this, it doesn't appear to be overly complex to implement. I'll try to write a patch for this later. -- Edit this bug report at http://bugs.php.net/bug.php?id=50973edit=1
Bug #53569 [Opn-Bgs]: Intermittent Seg Fault during DOMDocument clean up
Edit report at http://bugs.php.net/bug.php?id=53569edit=1 ID: 53569 Updated by: rricha...@php.net Reported by:chris dot richard at gmail dot com Summary:Intermittent Seg Fault during DOMDocument clean up -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: Linux (Ubuntu 10) PHP Version:5.3.2 Block user comment: N Private report: N New Comment: This is a bug in libxml2 which will be fixed in its 2.7.9 release. Unfortunately there is no simple workaround that can be done in the DOM extension for this without adding significant overhead just for this specific case. Previous Comments: [2010-12-20 17:30:24] chris dot richard at gmail dot com This script reproduces the issue fairly consistently on my machine: ? $doc = new DOMDocument(); $doc-loadXML( ?xml version='1.0'?. '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; [ !ENTITY nbsp #160; !ENTITY copy #169; !ENTITY ndash #8211; !ENTITY mdash #8212; ]'. html/); $fragment = $doc-createDocumentFragment(); $fragment-appendXML(head/headbodyinsert//body); $doc-documentElement-appendChild($fragment); ob_start(); ? ul lilorem ipsum dolor sit amet lorem ipsum dolor sit amet lorem ipsum dolor sit amet/li lilorem ipsum dolor sit amet lorem ipsum dolor sit amet/li lilorem ipsum dolor sit amet lorem ipsum dolor sit amet/li lilorem ipsum dolor sit amet lorem ipsum dolor sit amet/li /ul h2lorem ipsum dolor sit amet lorem ipsum dolor sit amet hr / /h2 plorem ipsum dolor sit amet lorem ipsum dolor sit amet/p pWhen the mortgage rate is 'fixed' it means that the rate (%) is set for the duration of the term, whereas with a variable mortgage rate, the rate fluctuates with the market interest rate, known as the 'prime rate'. So, for example, if the 5 year fixed mortgage rate is 4%, then you will pay 4% interest throughout the term of the mortgage./p plorem ipsum dolor sit amet lorem ipsum dolor sit amet/p h2Popularity of the 5-year fixed rate hr / /h2 h3 class=table-titleMortgages by length of term and age group/h3 table cellspacing=0 thead tr class=group-header thnbsp;/th th colspan=4Age group/th /tr tr class=column-headers thnbsp;/th th18-34/th th35-54/th th55+/th th class=totalAll ages/th /tr /thead tbody tr class=alternate th1 year term/th td5%/td td7%/td td6%/td td class=total6%/td /tr tr th2-4 year term/th td27%/td td18%/td td12%/td td class=total20%/td /tr tr class=highlight th5 year term/th td66%/td td65%/td td69%/td td class=total66%/td /tr tr th6-10 year term/th td3%/td td9%/td td10%/td td class=total7%/td /tr tr class=alternate thgt;10 year term/th td0/td td0/td td2%/td td class=total1%/td /tr /tbody /table ? $output = ob_get_clean(); $fragment = $doc-createDocumentFragment(); $fragment-appendXML($output); $xpath = new DOMXpath($doc); $insert = $xpath-query(.//insert)-item(0); $insert-parentNode-replaceChild($fragment, $insert); echo $doc-saveHTML(); ? [2010-12-18 16:57:51] cataphr...@php.net Can you provide a small script that reproduces this issue? It's complicated to find the error from backtraces that happen in the destruction phase; by this time the harm has long been done. Also please use the latest version of PHP. Thank you. [2010-12-18 06:16:59] chris dot richard at gmail dot com PHP 5.3.2 libxml 2.7.6 [2010-12-18 06:11:31] chris dot richard at gmail dot com Description: libxml causes a seg fault *intermittently* after all PHP user code has finished running. I'm using DOMFragment to parse chunks of XHTML and append them to a DOMDocument which gets output (via saveHTML) once it's completely assembled. The output completes successfully but at least half the time I get seg fault related to the clean up of the DOMDocument and no response is sent to the client. Core Dump: #0 0x7fb2f77c6e6f in xmlDictOwns () from /usr/lib/libxml2.so.2 #1 0x7fb2f77276a7 in xmlFreeNodeList () from /usr/lib/libxml2.so.2 #2 0x7fb2f76ff85f in ?? () from /usr/lib/libxml2.so.2 #3 0x7fb2f772f256 in xmlHashFree () from /usr/lib/libxml2.so.2 #4 0x7fb2f7727335 in xmlFreeDtd () from /usr/lib/libxml2.so.2 #5
Bug #52640 [Opn-Bgs]: Odd Garbage collection Behaviour with Dom Node
Edit report at http://bugs.php.net/bug.php?id=52640edit=1 ID: 52640 Updated by: rricha...@php.net Reported by:ken at smallboxcms dot com Summary:Odd Garbage collection Behaviour with Dom Node -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: Linux PHP Version:5.3.3 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php DOM objects are just wrappers to underlying libxml2 structures and unless directly referenced, i.e. $blah-node = $node, the $node object is no longer referenced outside of the function. Appending the node appends the libxml2 node structure to the underlying xml tree, does nothing in respect to the DOM object wrapper. Previous Comments: [2010-08-19 00:32:30] ken at smallboxcms dot com Description: Variables added to dom nodes are later unset. This behaviour does not appear to happen with other types of PHP objects. Test script: --- ?php $blah = new stdClass; function humbug() { /* Behaviour changes when uncommented. Think this is a GC bug. global $node; */ global $blah; $doc = new domDocument('1.0', 'utf-8'); $blah-doc = $doc; $node = $doc-createElement('node'); $doc-appendChild($node); $node-foo = true; $obj = new stdClass; $blah-obj = $obj; $obj-child = new stdClass; $obj-child-foo = true; } humbug(); echo Should be set: .$blah-doc-firstChild-foo.BR\n; echo Is Set: .$blah-obj-child-foo.BR\n; ? Expected result: I would expect that $blah-doc-firstChild-foo would be set after the function call. -- Edit this bug report at http://bugs.php.net/bug.php?id=52640edit=1
Req #53950 [Opn]: Add a way to configure where libxml searches for Catalog Files
Edit report at http://bugs.php.net/bug.php?id=53950edit=1 ID: 53950 Updated by: rricha...@php.net Reported by:gordon at onlinehome dot de Summary:Add a way to configure where libxml searches for Catalog Files Status: Open Type: Feature/Change Request Package:*XML functions Operating System: any PHP Version:Irrelevant -Assigned To: +Assigned To:rrichards Block user comment: N Private report: N New Comment: Assign to self as I asked him to open this Previous Comments: [2011-02-08 19:18:43] cataphr...@php.net This, by itself, makes it inviable to write a PHP function that allows replacing the default catalog unless some (probably expensive, since a catalog file must be read) on request startup/shutdown is used. The unless part doesn't actually make sense in the multi-threading versions of PHP. [2011-02-08 19:14:49] cataphr...@php.net I know very little of libxml2, but as far as I infer from http://xmlsoft.org/catalog.html and from the code in catalog.c, there is no way to specify a global catalog in a thread-local manner. This, by itself, makes it inviable to write a PHP function that allows replacing the default catalog unless some (probably expensive, since a catalog file must be read) on request startup/shutdown is used. libxml2 supports per-document catalogs, but from what I see, your document must contain an oasis-xml-catalog processing instruction, like this: ?xml version=1.0? ?oasis-xml-catalog catalog=http://example.com/catalog.xml;? !DOCTYPE doc PUBLIC -//Example//DTD Document V1.0//EN http://www.example.com/schema/doc.dtd; There is another alternative, which is using an external entity loader (see http://xmlsoft.org/html/libxml-parser.html#xmlSetExternalEntityLoader ), but this is less convenient, though probably we could also expose some functions to deal with catalogs for use in the user-supplied callback. I could implement this, but I'm hopping someone else with more libxml2 knowledge could tell if my analysis is correct. [2011-02-07 17:16:37] gordon at onlinehome dot de Description: Libxml can use catalog files to provide a local cache mechanism allowing to load the entities associated to public identifiers or remote resources. There is currently no way to configure the catalog file path from PHP. Configuring the path in libxml itself seems possible: The user can change the default catalog behaviour by redirecting queries to its own set of catalogs. This can be done by setting the XML_CATALOG_FILES environment variable to a list of catalogs, an empty one should deactivate loading the default /etc/xml/catalog default catalog. It would be nice if PHP's libxml extension would provide a way to set the path somehow. This could be helpful when validating documents with remote System Identifiers, like any HTML DTD. Or simply to bundle files with an application. Related Resources: - http://xmlsoft.org/catalog.html - http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic - http://bugs.php.net/48080 - http://bugs.php.net/32426 -- Edit this bug report at http://bugs.php.net/bug.php?id=53950edit=1
Req #30111 [Opn-Wfx]: Move some DOMDocument properties to static
Edit report at http://bugs.php.net/bug.php?id=30111edit=1 ID: 30111 Updated by: rricha...@php.net Reported by:phoeniks2k at mail dot ru Summary:Move some DOMDocument properties to static -Status: Open +Status: Wont fix Type: Feature/Change Request Package:DOM XML related Operating System: All PHP Version:5.0.1 Block user comment: N Private report: N New Comment: These are all per document settings and wont change to global. For consistent settings you are better off setting default settings to a var and always passing it to the $options parameter of the load method. Previous Comments: [2004-09-16 13:35:41] phoeniks2k at mail dot ru Description: It's likely to move # validateOnParse- default FALSE (will load and validate against DTD) resolveExternals - default FALSE (will load the DTD without performaing validation) preserveWhiteSpace - default TRUE substituteEntities - default FALSE # properties to statics It's good idea to define theese vars once for all exec time of the script -- Edit this bug report at http://bugs.php.net/bug.php?id=30111edit=1
Bug #52450 [Opn-Bgs]: $DomDocumentObj-encoding should not affect xml declaration
Edit report at http://bugs.php.net/bug.php?id=52450edit=1 ID: 52450 Updated by: rricha...@php.net Reported by:giorgio dot liscio at email dot it Summary:$DomDocumentObj-encoding should not affect xml declaration -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: all PHP Version:5.3.3 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php RTM Previous Comments: [2010-09-05 10:13:11] giorgio dot liscio at email dot it hi, can you examine my request? thank you [2010-07-26 23:58:02] giorgio dot liscio at email dot it Description: hi consider this code: i want to set utf-16 as internal encoding for domdocument because source data is utf-16 encoded $doc-encoding = UTF-16; but my output for web is handled by: iconv_set_encoding(internal_encoding, UTF-16); iconv_set_encoding(output_encoding, UTF-8//TRANSLIT//IGNORE); or can be handled by echo iconv(UTF-16, UTF-8, $xmldata); so the output is utf-8 encoded but the xml declaration says: ?xml version=1.0 encoding=UTF-16? so $document-encoding property should work as how it works now, but it should not affect the xml declaration in plus you should provide an alternative to set $xmlEncoding (make it non-readonly) i'm sorry for my english... i hope you accept this request! thank you -- Edit this bug report at http://bugs.php.net/bug.php?id=52450edit=1
Req #23313 [Opn-Wfx]: Missing DomNode-get_namespace()
Edit report at http://bugs.php.net/bug.php?id=23313edit=1 ID: 23313 Updated by: rricha...@php.net Reported by:markus dot pfefferle at web dot de Summary:Missing DomNode-get_namespace() -Status: Open +Status: Wont fix Type: Feature/Change Request Package:DOM XML related Operating System: * PHP Version:* Block user comment: N Private report: N New Comment: We are sorry, but we can not support PHP 4 related problems anymore. Momentum is gathering for PHP 6, and we think supporting PHP 4 will lead to a waste of resources which we want to put into getting PHP 6 ready. Previous Comments: [2003-04-23 06:56:03] markus dot pfefferle at web dot de It's nice that you can create nodes with namespaces, using DomDocument-create_element_ns() and DomNode-add_namespaces(), but for actually reading them, there is no counterpart method (other than prefix(), which is not very safe). My specific problem is that I want to clone a node without its child nodes, but can't use DomNode-clone_node(false), since this does not copy any namespace declarations and attributes either. Adding a DomNode-get_namespace() in future versions would be greatly appreciated. -- Edit this bug report at http://bugs.php.net/bug.php?id=23313edit=1
Bug #53393 [Opn-Bgs]: XPath path issue with namespaced elements created with DOMDocument
Edit report at http://bugs.php.net/bug.php?id=53393edit=1 ID: 53393 Updated by: rricha...@php.net Reported by:paul dot visco at roswellpark dot org Summary:XPath path issue with namespaced elements created with DOMDocument -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: CENTOS 5.5/Fedora 14 PHP Version:5.3.3 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php must use dom level 2 namespace aware methods Previous Comments: [2010-11-24 04:01:43] paul dot visco at roswellpark dot org Description: When creating a namespaced DOMDocument programmatically (appendChild, etc), I cannot get DOMXPath to return the same results on the same underlying XML document as I can when use DOMDocument-loadXML() to populate the documents XML. I compiled and tested the latest PHP 5.3.4RC2-dev (cli) (built: Nov 23 2010 21:51:46) using --with-dom and --with-xml and used the latest stable libxml2-devel.x86_64 2.7.7-2.fc14 from fedora 14 and the problem still persists. Sorry its like 25 lines of code with comments, I don't have somewhere else to put them. Test script: --- //Constructing the DOMDocument from XML string allows DOMXPath to work $xml = EOT ?xml version=1.0 encoding=UTF-8? entry xmlns=http://www.w3.org/2005/Atom; xmlns:other=http://other.w3.org/other;iduYG7-sPwjFg/idpublished2009-05-17T18:29:31.000Z/published/entry EOT; $doc = new DOMDocument; $doc-loadXML($xml); $xpath = new DOMXPath($doc); $xpath-registerNamespace('atom', http://www.w3.org/2005/Atom;); $entries = $xpath-evaluate('//atom:entry/atom:published/text()'); ///prints 2009-05-17T18:29:31.000Z as expected print $entries-item(0)-nodeValue ; //Constructing the same exact document programmatically causes DOMXPath to not work $doc = new DOMDocument(1.0, UTF-8); $entry = $doc-createElement('entry'); $doc-appendChild($entry); $entry-setAttribute('xmlns', http://www.w3.org/2005/Atom;); $entry-setAttribute('xmlns:other', http://other.w3.org/other;); $id = $entry-appendChild($doc-createElement('id'));; $id-appendChild($doc-createTextNode(uYG7-sPwjFg)); $published = $entry-appendChild($doc-createElement('published')); $published-appendChild($doc-createTextNode(2009-05-17T18:29:31.000Z)); $xpath = new DOMXPath($doc); $xpath-registerNamespace('atom', http://www.w3.org/2005/Atom;); $entries = $xpath-evaluate('//atom:entry/atom:published/text()'); //throws error as node is not found print $entries-item(0)-nodeValue; Expected result: I would expect both of the above examples to print 2009-05-17T18:29:31.000Z Actual result: -- Example one prints 2009-05-17T18:29:31.000Z and example 2 fails because the node is not found by Xpath -- Edit this bug report at http://bugs.php.net/bug.php?id=53393edit=1
Bug #53044 [Opn-Bgs]: Invalid Nodetype to import
Edit report at http://bugs.php.net/bug.php?id=53044edit=1 ID: 53044 Updated by: rricha...@php.net Reported by:bbarnetm at yahoo dot com Summary:Invalid Nodetype to import -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: W2K3 PHP Version:5.2.14 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: [2010-10-12 06:55:14] bbarnetm at yahoo dot com I modified my script following your tip I founded enough information for incluye aditional lines: $xmlestilos=ereg_replace([\\Ã]+,,($xmlestilos)); $xmlestilos=ereg_replace([\\ð]+,,($xmlestilos)); The script was modified: if (!($dom-loadXML($xmlestilos))){ $errors = libxml_get_errors(); foreach ($errors as $error) { echo display_xml_error($error, $xmlestilos); } libxml_clear_errors(); } Thank very much for your tip. Let me know if in a future versions you will increment the power of xml functions? [2010-10-12 05:55:34] cataphr...@php.net I'd guess the DOMDocument object is empty because the call to loadXML() failed. You should do if (!$dom-loadXML(...)) { //error loading XML. Call libxml_get_errors() to get details } not if (!$dom) { Please confirm this is the case. In any case, the error message could be better... [2010-10-11 21:22:24] bbarnetm at yahoo dot com function acentos($valor){ //Le elimina los acentos al string recibido $registro=$valor; $registro=ereg_replace(á,a,($registro)); $registro=ereg_replace(é,e,($registro)); $registro=ereg_replace(Ã,i,($registro)); $registro=ereg_replace(ó,o,($registro)); $registro=ereg_replace(ú,u,($registro)); $registro=ereg_replace(Ã,A,($registro)); $registro=ereg_replace(Ã,E,($registro)); $registro=ereg_replace(Ã,I,($registro)); $registro=ereg_replace(Ã,O,($registro)); $registro=ereg_replace(Ã,U,($registro)); $registro=ereg_replace(ñ,n,($registro)); $registro=ereg_replace(Ã,N,($registro)); return $registro; } [2010-10-11 21:14:18] bbarnetm at yahoo dot com Description: While I'm trying to import an extensive xml, I'm recieving the same error while I try to transale to simple xml. Test script: --- libxml_use_internal_errors(true); $xmlestilos=ereg_replace(chr(160),,(trim($reg[0]))); $xmlestilos=ereg_replace('',,$xmlestilos); $xmlestilos=ereg_replace(,,.,$xmlestilos); $xmlestilos=ereg_replace(amp;,,$xmlestilos); $xmlestilos=ereg_replace(gt,,$xmlestilos); $xmlestilos=ereg_replace(},,$xmlestilos); $xmlestilos=ereg_replace(#,,$xmlestilos); $xmlestilos=ereg_replace(`,,$xmlestilos); $xmlestilos=ereg_replace(;,,$xmlestilos); $xmlestilos=ereg_replace([\\|]+,,$xmlestilos); $xmlestilos=ereg_replace([\\]+,/,$xmlestilos); $xmlestilos=ereg_replace(¦,,($xmlestilos)); $xmlestilos=ereg_replace(º,,($xmlestilos)); $xmlestilos=ereg_replace(´,,($xmlestilos)); $xmlestilos=ereg_replace(¨,,($xmlestilos)); $xmlestilos=ereg_replace([\\?]+,,($xmlestilos)); $xmlestilos=ereg_replace([\\¿]+,,($xmlestilos)); $xmlestilos=acentos($xmlestilos); $xmlestilos=stripslashes($xmlestilos); $xmlestilos=utf8_decode($xmlestilos); $dom = new domDocument; $dom-loadXML($xmlestilos); if (!$dom) { //Escribe la respuesta en un archivo $formato1 = '%d%m%Y'; $hoyes = strftime($formato1); $archivolog=estilos_.$hoyes..log; if (file_exists($archivolog)){unlink($archivolog);} $fp = fopen ($archivolog, a); //fwrite ($fp, trim($reg[0]). PHP_EOL); fwrite ($fp, trim($xmlestilos). PHP_EOL); fclose($fp); print 'MSG-18: SE DETECTO UNA RESPUESTA INVALIDA DEL INS'; die(); } $xml = simplexml_import_dom($dom); Expected result: The xml imported in a simple xml object Actual result: -- Warning: simplexml_import_dom() [function.simplexml-import-dom]: Invalid Nodetype to import in E:\SITIOS\PayWebCoopemex\INS\ins-405.srv.php on line 149
Bug #53694 [Opn-Bgs]: SimpleXMLElement does not read XML declaration line.
Edit report at http://bugs.php.net/bug.php?id=53694edit=1 ID: 53694 Updated by: rricha...@php.net Reported by:jamone_95134 at yahoo dot com Summary:SimpleXMLElement does not read XML declaration line. -Status: Open +Status: Bogus Type: Bug Package:SimpleXML related Operating System: Windows XP PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php invalid characters before start of declaration. Previous Comments: [2011-01-08 10:04:15] jamone_95134 at yahoo dot com Description: --- From manual page: http://www.php.net/simplexml.examples-basic --- When I run the first example I get the following errors: $ php test1.php Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : XML declaration allowed only at the start of th e document in D:\php_src\XML\test1.php on line 4 Warning: SimpleXMLElement::__construct(): ?xml version=1.0 encoding=utf-8? in D:\php_src\XML\test1.php on li ne 4 Warning: SimpleXMLElement::__construct():^ in D:\php_src\XML\test1.php on line 4 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in D:\php_src\XML\test1.php :4 Stack trace: #0 D:\php_src\XML\test1.php(4): SimpleXMLElement-__construct('??xml version=...') #1 {main} thrown in D:\php_src\XML\test1.php on line 4 If I remove the ?xml version=1.0 encoding=utf-8? line from the example.php file it runs ok. So how do we handle the declaration line for xml files with SimpleXMLElement? Test script: --- Just running example 2 from http://www.php.net/manual/en/simplexml.examples-basic.php Expected result: Expected result: So, this language. It's like, a programming language. Or is it a scripting language? All is revealed in this thrilling horror spoof of a documentary. Actual result: -- $ php test1.php Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : XML declaration allowed only at the start of th e document in D:\php_src\XML\test1.php on line 4 Warning: SimpleXMLElement::__construct(): ?xml version=1.0 encoding=utf-8? in D:\php_src\XML\test1.php on li ne 4 Warning: SimpleXMLElement::__construct():^ in D:\php_src\XML\test1.php on line 4 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in D:\php_src\XML\test1.php :4 Stack trace: #0 D:\php_src\XML\test1.php(4): SimpleXMLElement-__construct('??xml version=...') #1 {main} thrown in D:\php_src\XML\test1.php on line 4 -- Edit this bug report at http://bugs.php.net/bug.php?id=53694edit=1
Bug #53677 [Csd-Bgs]: xml_parse_into_struct deletes unescaped character data
Edit report at http://bugs.php.net/bug.php?id=53677edit=1 ID: 53677 Updated by: rricha...@php.net Reported by:lwc at mailmetrash dot com Summary:xml_parse_into_struct deletes unescaped character data -Status: Closed +Status: Bogus Type: Bug Package:XML related Operating System: Redhat Linux PHP Version:5.2.14 Block user comment: N Private report: N New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. dupe of bug #45996 Previous Comments: [2011-01-07 01:25:26] lwc at mailmetrash dot com Sorry, you can delete this bug. The fixed description made me realize it's a duplicate of #45996. [2011-01-06 22:05:23] lwc at mailmetrash dot com Sorry, here's a fixed description. thislt;thatgt;taglt;that/gt;/this should turn into: [name] = this [value] = thattag/that But in some cases it turns into: [name] = this [value] = tag/ That is, it's not even kept. It's just deleted! [2011-01-06 21:48:10] lwc at mailmetrash dot com As for the (as claimed in) comment, you can delete it. They actually claim you should use straight up HTML without escaping it. Problem is the parser then treats the HTML tags like XML ones. If you have a solution for that one, please post it there. [2011-01-06 21:40:58] lwc at mailmetrash dot com Description: Assuming #26528 is also valid for the actual character data (as claimed in http://forum.alicebot.org/viewtopic.php?t=69), then the parser should decode thislt;thatgt;/this into: [name] = this [value] = that The problem is in some cases it stays as: [name] = this [value] = lt;thatgt; In my 2 unrelated servers, the decoding works in v5.2.6 but fails in v5.2.14. Please check in newer versions, if you can! -- Edit this bug report at http://bugs.php.net/bug.php?id=53677edit=1
Req #53655 [Opn-Asn]: Improve speed of DOMNode::C14N() on large XML documents
Edit report at http://bugs.php.net/bug.php?id=53655edit=1 ID: 53655 Updated by: rricha...@php.net Reported by:olav dot morken at uninett dot no Summary:Improve speed of DOMNode::C14N() on large XML documents -Status: Open +Status: Assigned Type: Feature/Change Request Package:DOM XML related PHP Version:5.3.4 -Assigned To: +Assigned To:rrichards Block user comment: N Private report: N Previous Comments: [2011-01-05 08:33:02] olav dot morken at uninett dot no Description: The C14N() function appears to have a runtime that is O(N^2) (or possibly worse?) depending on input size, which means that it becomes very slow as the input grows. For example, an input with around 196000 nodes takes about 290 seconds, while an input with 486000 nodes takes 2200 seconds. Note that this problem only occurs when canonicalizing a subtree of the docuemnt. If we canonicalize the whole document, it completes almost immediately. The problem is that canonicalization uses an XPath expression to find the nodeset that should be canonicalized. Evaluation of the XPath expression takes a lot of time as the input size grows, but the libxml2 xmlC14NDocSaveTo() function also has to do a lookup in the nodeset returned by the XPath expression for every node it encounters. I believe a better solution would be to do this like it is done in the xmlsec library. This library use the xmlC14NExecute()-function instead, which accepts a callback that determines whether a node should be included in the result. This should make the speed of canonicalization linear with the input size. Test script: --- ?php $doc = new DOMDocument(); $doc-load('some-large-xml-file.xml'); $start = microtime(TRUE); $doc-documentElement-C14N(FALSE, FALSE); echo Done in . (microtime(TRUE) - $start) . seconds.\n; -- Edit this bug report at http://bugs.php.net/bug.php?id=53655edit=1
Bug #45996 [Csd]: libxml2 2.7.1 causes breakage with character data in xml_parse()
Edit report at http://bugs.php.net/bug.php?id=45996edit=1 ID: 45996 Updated by: rricha...@php.net Reported by:phpbugs at colin dot guthr dot ie Summary:libxml2 2.7.1 causes breakage with character data in xml_parse() Status: Closed Type: Bug Package:XML related Operating System: Mandriva Linux PHP Version:5.2.6 Assigned To:rrichards Block user comment: N Private report: N New Comment: To hopefully close this once and for all: Compile PHP (5.2.9 or higher) against the newer libxml (2.7.3 or higher). PHP code change: http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/ext/xml/compat.c? r1=272374r2=273286 Libxml code change: http://svn.gnome.org/viewvc/libxml2/trunk/parser.c?r1=3803r2=3807 Previous Comments: [2011-01-04 19:50:35] lwc at mailmetrash dot com It still happens to me even in libxml v2.7.7. Please take it seriously. At least mention in what scenarios does it happen and does it have a link in libxml's own bug tracker. [2010-07-07 23:17:53] i_cypher at hotmail dot com I am seeing this error in 2.7.3 as well, so the fix does not seem to be working. [2010-04-19 00:05:30] nick dot phillips at otago dot ac dot nz Just FYI - I have been seeing what would appear to be this issue with libxml2 2.7.6 (with Moodle), so it seems that 2.7.3 or higher doesn't cut it. Reverting to 2.6.32 solved the problem for me. [2009-01-11 12:06:01] rricha...@php.net This bug has been fixed in CVS. 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/. Thank you for the report, and for helping us make PHP better. This fix also requires the soon to be released libxml2-2.7.3 or higher when using 2.7.x. [2009-01-03 04:03:53] david+phpbugs at midrange dot com Ok, I'm going to try and rebuild the Fedora 8 source RPM to avoid the libxml2 bug ... but I'm not all that familiar with how PHP is built ... and could use a pointer or two on what to change on the configure command line. Any suggestions? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=45996 -- Edit this bug report at http://bugs.php.net/bug.php?id=45996edit=1
Bug #45996 [Csd]: libxml2 2.7.1 causes breakage with character data in xml_parse()
Edit report at http://bugs.php.net/bug.php?id=45996edit=1 ID: 45996 Updated by: rricha...@php.net Reported by:phpbugs at colin dot guthr dot ie Summary:libxml2 2.7.1 causes breakage with character data in xml_parse() Status: Closed Type: Bug Package:XML related Operating System: Mandriva Linux PHP Version:5.2.6 Assigned To:rrichards Block user comment: N Private report: N New Comment: HTML is not XML so non issue as the sax parser is not meant to handle HTML If PHP is not linked against 2.7.3 or higher it wont work either. So back to Compile PHP (5.2.9 or higher) against the newer libxml (2.7.3 or higher) as most of those search results even tell you. Without phpinfo and your sample code I would say the problem is on your end Previous Comments: [2011-01-04 21:54:53] lwc at mailmetrash dot cm Regarding your e-mail message, please let's continue this discussion publicly. It's established that this bug can happen with any (HTML) input, so there's no point exposing my own. Check out http://www.google.com/search?q=libxml+%2Bbrackets for tons of example code. But most importantly, is it possible that all this time no one ever posted a bug about it in libxml's own tracker? If so, I think I'll post something there soon. [2011-01-04 20:55:54] lwc at mailmetrash dot com Again, I use libxml v2.7.7 (with PHP v5.2.14). [2011-01-04 20:04:33] rricha...@php.net To hopefully close this once and for all: Compile PHP (5.2.9 or higher) against the newer libxml (2.7.3 or higher). PHP code change: http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/ext/xml/compat.c? r1=272374r2=273286 Libxml code change: http://svn.gnome.org/viewvc/libxml2/trunk/parser.c?r1=3803r2=3807 [2011-01-04 19:50:35] lwc at mailmetrash dot com It still happens to me even in libxml v2.7.7. Please take it seriously. At least mention in what scenarios does it happen and does it have a link in libxml's own bug tracker. [2010-07-07 23:17:53] i_cypher at hotmail dot com I am seeing this error in 2.7.3 as well, so the fix does not seem to be working. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=45996 -- Edit this bug report at http://bugs.php.net/bug.php?id=45996edit=1
Bug #53628 [Opn-Bgs]: Lack of support for character references
Edit report at http://bugs.php.net/bug.php?id=53628edit=1 ID: 53628 Updated by: rricha...@php.net Reported by:alexander dot grimalovsky at gmail dot com Summary:Lack of support for character references -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: All PHP Version:5.3.4 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php createEntityReference works per spec. It is only supposed to support entity references - not character references. You typically use a text node with escaped data to add characters. Previous Comments: [2010-12-29 17:58:21] alexander dot grimalovsky at gmail dot com Description: DOM extension for PHP supports XML entity references by implementing DOMEntityReference class. However due to incorrect entity name validation this class only allows working with named entity references, not character references. libxml2, which is used as backend implementation for DOM XML operations have 2 functions for creating entity references: xmlNewReference() - for entity references, it is used by DOM extension xmlNewCharRef() - for character references, it is not used by DOM extension and hence causes extension to lack support for this kind of entities. Moreover, implementation of DOMEntityReference::__construct() in ext/dom/entityreference.c uses libxml2 function xmlValidateName() for validating entity name which checks for Name (see http://www.w3.org/TR/REC-xml/#NT-EntityRef). Of course this check is failed on character references ( see http://www.w3.org/TR/REC-xml/#NT-CharRef) and hence causes exception or warning error to be thrown. Correct implementation should check for # character at a first position of given entity name and call xmlNewReference() or xmlNewCharRef() depending on test result. PHP 5.2.x is also affected by this problem. Test script: --- ?php $xml = new DOMDocument('1.0','utf-8'); $node = $xml-createElement('test'); $xml-appendChild($node); $named = $xml-createEntityReference('entity'); // Create named entity, works $node-appendChild($named); $char = $xml-createEntityReference('#xAA');// Create character reference, doesn't work $node-appendChild($char); echo $xml-saveXML(); Expected result: ?xml version=1.0 encoding=utf-8? testentity;#xAA;/test Actual result: -- Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in test.php:7 Stack trace: #0 test.php(7): DOMDocument-createEntityReference('#xAA') #1 {main} thrown in test.php on line 7 -- Edit this bug report at http://bugs.php.net/bug.php?id=53628edit=1
Bug #53192 [Opn-Bgs]: SimpleXML ignores XSI:TYPE attributes
Edit report at http://bugs.php.net/bug.php?id=53192edit=1 ID: 53192 Updated by: rricha...@php.net Reported by:jesse at eonstreet dot com Summary:SimpleXML ignores XSI:TYPE attributes -Status: Open +Status: Bogus Type: Bug Package:SimpleXML related Operating System: Windows 7 64bit PHP Version:5.3.3 Block user comment: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php it works based on namespace scope so you need to tell it what namespace is in current scope for it to access the elements/attributes Previous Comments: [2010-10-28 16:01:01] jesse at eonstreet dot com Description: Hello, It seems that SimpleXML removed all references to xsi:type in every node. XML Parser does show the xsi:type as an attribute. The code below demonstrates this. Test script: --- $xmlData = 'root xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; node xsi:type=TestDATA/node/root'; // Try First with SimpleXml $xml = simplexml_load_string($xmlData); echo Node XSI:TYPE = . (string)$xml-node['xsi:type']; // Try using XML Parser function tag_open($parser, $tag, $attributes) { if (!empty($attributes)) { echo br / Tag: $tag Atrributes: .print_r($attributes,true); } } $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($parser, tag_open, false); xml_parse($parser, ltrim($xmlData)); Expected result: Node XSI:TYPE = Test Tag: root Atrributes: Array ( [xmlns:xsi] = http://www.w3.org/2001/XMLSchema-instance ) Tag: node Atrributes: Array ( [xsi:type] = Test ) Actual result: -- Node XSI:TYPE = Tag: root Atrributes: Array ( [xmlns:xsi] = http://www.w3.org/2001/XMLSchema-instance ) Tag: node Atrributes: Array ( [xsi:type] = Test ) -- Edit this bug report at http://bugs.php.net/bug.php?id=53192edit=1
Bug #52782 [Opn-Bgs]: DOMDocument subclass forgotten using -ownerDocument after closure
Edit report at http://bugs.php.net/bug.php?id=52782edit=1 ID: 52782 Updated by: rricha...@php.net Reported by:bugs dot php dot net at moesen dot nu Summary:DOMDocument subclass forgotten using -ownerDocument after closure -Status: Open +Status: Bogus Type: Bug Package:DOM XML related Operating System: GNU/Linux 2.6.26-2-686 (Debian) PHP Version:5.3SVN-2010-09-06 (snap) Block user comment: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is by design to minimize the system resource impact. The behavior you describe was the old behavior used in the domxml extension and purposely not duplicated. Objects wrapping the underlying XML tree live only as long as the user has a reference to them otherwise the only way to destroy any DOM object would be to de-reference every single object that wraps any portion on the underlying xml tree. Previous Comments: [2010-10-07 11:32:14] bugs dot php dot net at moesen dot nu (Following up on e-mail correspondance with rrichards at php dot net.) It'd most likely due to scoping. If you create an element based on a subclass, it will only return the subclass as long as the element's object (the DOM wrapper not the underlying XML structure) no longer has any references. There are a couple ways to work around this: 1 - Always keep the doc object in global scope with at least 1 reference to it. This really is only needed if you are attaching custom data to any custom properties. This does indeed work around the problem, but I am not keen on polluting the global namespace. 2 - The best way is to use: bool DOMDocument::registerNodeClass ( string $baseclass , string $extendedclass ) http://us2.php.net/manual/en/domdocument.registernodeclass.php Using this mehod, you can register classes to always create specific node types with rather than the default DOM classes so if you have any custom methods they will always be available i.e. class myDoc extends DOMDocument { }; $doc = new myDoc(); $doc-registerNodeClass(DOMDocument, myDoc); That works to a certain extent: the class is correct, but its custom properties are lost, as mentioned in work-around 1. The ownerDocument is an instance of MyDocument, but instead of being the original instance, it is a new instance (without calling the constructor) with all of its properties set to their defaults. It seems to me that as long as there is a DOMElement, there is an implicit reference to the original instance of the owner document (because of $domElement-ownerDocument), so said document should not be garbage collected. I have uploaded a simplified test case at http://codepad.org/CBsD3eVp [2010-09-20 13:19:34] bugs dot php dot net at moesen dot nu Is there anything I can do to get a confirmation on this? I tried #php on several networks, but they referred me to Freenode, where #php was full. [2010-09-06 15:43:15] bugs dot php dot net at moesen dot nu Err, my apologies for not cleaning up the path names. An oversight on my part. [2010-09-06 15:35:59] bugs dot php dot net at moesen dot nu Description: We have custom XML document and element classes that extend the original DOMDocument and DOMElement classes for convenience. There is a class that uses an instance of XmlElement obtained via a callback specified at construction time. That XmlElement works fine and stays that way. However, when we get its ownerDocument outside of the closure, the result is not an XmlDocument but a DOMDocument. I cannot see a single reason why. I tried several options, and it only seems to happen with that closure. I have checked versions 5.3.1, 5.3.2, 5.3.3 and now the latest 5.3.4 snapshot compiled with './configure make'. Test script: --- http://codepad.org/hvrNh86K The original code uses a lot of namespaces and extends XmlDocument, but this is a much more minimal test case. Also try the Uncomment this code to see what /does/ work. Expected result: *** Calling the callback directly... dom-fail.php:110: $container: XmlElement: div id=content/ dom-fail.php:111: $container-ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } *** Calling callback from constructor()... dom-fail.php:110: $container: XmlElement: div id=content/ dom-fail.php:111: $container-ownerDocument: XmlDocument; debug
Bug #52998 [Asn-Bgs]: memory content leak when using invalid utf-8 with XMLWriter::writeAttribute
Edit report at http://bugs.php.net/bug.php?id=52998edit=1 ID: 52998 Updated by: rricha...@php.net Reported by:kees at outflux dot net Summary:memory content leak when using invalid utf-8 with XMLWriter::writeAttribute -Status: Assigned +Status: Bogus Type: Bug Package:XML Writer Operating System: Ubuntu 10.10 PHP Version:5.3.3 Assigned To:rrichards Block user comment: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. You just reported the same bug to libxml2 bug system. Will be handled there Previous Comments: [2010-10-06 21:25:48] paj...@php.net Rob, does it ring a bell? It could be a bug in libxml? [2010-10-06 20:38:47] kees at outflux dot net This was discovered in Ubuntu, btw: https://bugs.launchpad.net/php/+bug/655442 [2010-10-06 03:52:16] kees at outflux dot net Description: It seems that PHP is not correctly using libxml2's xmlwriter routines, and allows passing in invalid utf-8 strings which are then misparsed by libxml2, allowing memory contents to leak into the resulting output. Test script: --- ?php # Copyright 2010, Canonical, Ltd. # Author: Kees Cook k...@ubuntu.com # License: GPLv3 # # Proof-of-concept memory content leak $xw = new XMLWriter(); $xw-openURI('php://output'); $xw-startElement('input'); $xw-writeAttribute('value', \xe0\x81); $xw-endElement(); ? Expected result: input value=#xe0;#e81/ Actual result: -- PHP Warning: XMLWriter::writeAttribute(): string is not in UTF-8 in /tmp/xmlwriter.php on line 12 input value=#x40;#xB1;�Ë[����ĹJ���R���Q/ -- Edit this bug report at http://bugs.php.net/bug.php?id=52998edit=1
Bug #52661 [Opn-Fbk]: lookupNamespaceURI returns nothing
Edit report at http://bugs.php.net/bug.php?id=52661edit=1 ID: 52661 Updated by: rricha...@php.net Reported by:tim at buyplaytix dot com Summary:lookupNamespaceURI returns nothing -Status: Open +Status: Feedback Type: Bug Package:DOM XML related Operating System: Ubuntu maverick PHP Version:5.3.3 Block user comment: N New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. most likely its due to how you are removing and adding them back in. Need a reproducible script to determine if this is really a bug in DOM or not Previous Comments: [2010-08-20 20:07:34] tim at buyplaytix dot com Description: Hopefully this is something that's fairly easy to see in the code. Providing a full working code sample will be somewhat difficult. This seems to happen most frequently with nodes that have been removed from the dom and added back elsewhere. Basically if I call lookupNamespace on a node I'm getting nothing back. If I load the node into SimpleXML and call getNamespaces I'm getting the namespace as expected. The attached code is a workaround for the problem. Test script: --- private function get_namespace($node) { $node_namespace = $node-lookupNamespaceURI($node-prefix); if($node instanceof DomElement $node_namespace == null strpos($node-nodeName, :) !== false) { // must be some sort of DOM bug. Look and see if we can figure it out from simplexml $sxe = simplexml_import_dom($node); $namespaces = $sxe-getNamespaces(); foreach($namespaces as $prefix = $namespace) { if(strpos($node-nodeName, $prefix . :) == 0) { $node_namespace = $namespace; break; } } } return $nodeNamespace; } Expected result: I expect that if I get into the body of the if statement that I will return a null $node_namespace. Preferably I'd never get into the if statement. -- Edit this bug report at http://bugs.php.net/bug.php?id=52661edit=1
Bug #51897 [Fbk-Bgs]: LIBXML_NOWARNING does not suppress warnings when passed to xinclude().
Edit report at http://bugs.php.net/bug.php?id=51897edit=1 ID: 51897 Updated by: rricha...@php.net Reported by: rquadl...@php.net Summary: LIBXML_NOWARNING does not suppress warnings when passed to xinclude(). -Status: Feedback +Status: Bogus Type: Bug Package: DOM XML related Operating System: Windows XP SP3 PHP Version: 5.3.2 Assigned To: rrichards New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. the underlying xinclude code is not checking those options when issuing warnings so needs to be fixed on the libxml2 layer. You either need to surpress warnings for that call or use internal error handling so they are not directly issued to output/log. Previous Comments: [2010-06-21 13:05:51] rquadl...@php.net OOI, this code is using ... PHP 5.3.3-RC1 (cli) (built: Jun 17 2010 22:43:29) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies and Extension [ persistent extension #23 libxml version no_version ] { - Constants [22] { Constant [ integer LIBXML_VERSION ] { 20707 } Constant [ string LIBXML_DOTTED_VERSION ] { 2.7.7 } Constant [ string LIBXML_LOADED_VERSION ] { 20707 } [2010-06-21 13:04:52] rquadl...@php.net This is about as short as I can get. I can't work out how to get the xinclude working in this example, but that is not the issue. The warning that is generated is the issue. Only the code below is required - no PHPDoc or DocBook, etc. ?php file_put_contents('my.dtd', END_DTD !ENTITY % db.common.attributes xml:id ID #IMPLIED !ENTITY % db.common.linking.attributes xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude' !ELEMENT people_list (person*) !ATTLIST people_list %db.common.attributes; %db.common.linking.attributes; !ELEMENT person (name, birthdate?, gender?, socialsecuritynumber?) !ATTLIST person %db.common.attributes; %db.common.linking.attributes; !ELEMENT name (#PCDATA) !ELEMENT birthdate (#PCDATA) !ELEMENT gender (#PCDATA) !ELEMENT socialsecuritynumber (#PCDATA) END_DTD ); file_put_contents('my.xml', END_XML ?xml version=1.0 encoding=UTF-8? !DOCTYPE people_list SYSTEM my.dtd people_list xmlns:xi=http://www.w3.org/2001/XInclude; person xml:id=fred nameFred Bloggs/name birthdate27/11/2008/birthdate genderMale/gender /person person xml:id=john nameJohn Bloggs/name genderMale/gender !-- Include fred's birthdate -- xi:include xpointer=xmlns(db=my.dtd) xpointer(id('fred')/db:birthdate) xi:fallback / /xi:include /person /people_list END_XML ); echo file_get_contents('my.dtd'), PHP_EOL, PHP_EOL, file_get_contents('my.xml'), PHP_EOL, PHP_EOL; $doc = new DOMDocument(); $doc-load('my.xml', LIBXML_NOENT); var_dump($doc-xinclude(LIBXML_NOWARNING)); var_dump($doc-validate()); $doc-save('final.xml'); echo PHP_EOL, file_get_contents('final.xml'); unlink('final.xml'); unlink('my.dtd'); unlink('my.xml'); ? Other than the XML and the DTD, the output is ... Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=my.dtd) xpointer(id('fred')/db:birthdate) in Z:\testinc.php on line 49 int(-1) bool(true) The Warning is present, even though LIBXML_NOWARNING is present. I believe that the issue is that xinclude processing doesn't look at the same flags as the xml parser. But that's just a half-arsed guess at trying to read the c code of something I'm clearly not understanding 100% Richard. [2010-06-18 20:19:45] rricha...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. please submit a test case that doesnt require phpdoc to be pulled [2010-05-24 12:35:56] rquadl...@php.net Description
Bug #51785 [Asn-Bgs]: No way to escape quotes for XPath
Edit report at http://bugs.php.net/bug.php?id=51785edit=1 ID: 51785 Updated by: rricha...@php.net Reported by: pecoes at gmail dot com Summary: No way to escape quotes for XPath -Status: Assigned +Status: Bogus Type: Bug Package: *XML functions Operating System: WinXP PHP Version: 5.3.2 Assigned To: rrichards New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to take into account PHP string escaping too. $q = /test[text()='\']; For more complex situations with mixed quote types, its a general overall issue with XPath not a PHP bug. Previous Comments: [2010-05-10 18:43:43] pecoes at gmail dot com Description: There seems to be no way to escape single or double quotes for XPath-Queries. given: test/test /test[text()=\] produces an error message /test[text()=\\] dito /test[text()=quot;] finds no match This is not a PHP-Bug, I suppose. It may be a bug in the libxml2. It might even be a bug in the XPath Spec itself. But regardless of where the blame lies: This is serious! How is one supposed to use user-input in an XPath, if it cannot be escaped? I found a work-around, but it's fugly: $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); function xquote ($str) { if (strpos($str, '') === FALSE) { return ''.$str.''; } if (strpos($str, ') === FALSE) { return '.$str.'; } $parts = preg_split('/()/', $str, 0, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); array_walk($parts, function ($val) { if ($val == '') $val = '\'; else $val = ''.$val.''; } ); return 'concat('.implode(',', $parts).')'; } $q = sprintf('/test[text()=%s]', xquote('')); if ($xpath-evaluate($q)-item(0)) { echo 'found'; // works! } else { echo 'not found'; } Test script: --- $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); $q = '/test[text()=quot;]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } $q = '/test[text()=\\]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } Expected result: found found Actual result: -- not found Warning: DOMXPath::evaluate(): Invalid predicate... Warning: DOMXPath::evaluate(): Invalid expression... Fatal error: Call to a member function item() on non-object... -- Edit this bug report at http://bugs.php.net/bug.php?id=51785edit=1
Bug #51785 [Bgs]: No way to escape quotes for XPath
Edit report at http://bugs.php.net/bug.php?id=51785edit=1 ID: 51785 Updated by: rricha...@php.net Reported by: pecoes at gmail dot com Summary: No way to escape quotes for XPath Status: Bogus Type: Bug Package: *XML functions Operating System: WinXP PHP Version: 5.3.2 Assigned To: rrichards New Comment: Jeez. Learn to properly escape strings then. I even gave you the proper code for your test to work. Its not a PHP bug nor a libxml2 bug so it's bogus. Regardless of the language you use you will hit escaping issues. If you really think its a bug somewhere you need to take it to the W3C. Previous Comments: [2010-06-18 16:33:42] pecoes at gmail dot com Alright. It's not a PHP bug. So... what now? How do I deal with it in PHP? Just because PHP is innocent, doesn't mean there's no need for a fix. It's still a bug! Classifying it as bogus won't do a thing. [2010-06-18 16:22:05] rricha...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to take into account PHP string escaping too. $q = /test[text()='\']; For more complex situations with mixed quote types, its a general overall issue with XPath not a PHP bug. [2010-05-10 18:43:43] pecoes at gmail dot com Description: There seems to be no way to escape single or double quotes for XPath-Queries. given: test/test /test[text()=\] produces an error message /test[text()=\\] dito /test[text()=quot;] finds no match This is not a PHP-Bug, I suppose. It may be a bug in the libxml2. It might even be a bug in the XPath Spec itself. But regardless of where the blame lies: This is serious! How is one supposed to use user-input in an XPath, if it cannot be escaped? I found a work-around, but it's fugly: $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); function xquote ($str) { if (strpos($str, '') === FALSE) { return ''.$str.''; } if (strpos($str, ') === FALSE) { return '.$str.'; } $parts = preg_split('/()/', $str, 0, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); array_walk($parts, function ($val) { if ($val == '') $val = '\'; else $val = ''.$val.''; } ); return 'concat('.implode(',', $parts).')'; } $q = sprintf('/test[text()=%s]', xquote('')); if ($xpath-evaluate($q)-item(0)) { echo 'found'; // works! } else { echo 'not found'; } Test script: --- $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); $q = '/test[text()=quot;]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } $q = '/test[text()=\\]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } Expected result: found found Actual result: -- not found Warning: DOMXPath::evaluate(): Invalid predicate... Warning: DOMXPath::evaluate(): Invalid expression... Fatal error: Call to a member function item() on non-object... -- Edit this bug report at http://bugs.php.net/bug.php?id=51785edit=1
Bug #51785 [Bgs]: No way to escape quotes for XPath
Edit report at http://bugs.php.net/bug.php?id=51785edit=1 ID: 51785 Updated by: rricha...@php.net Reported by: pecoes at gmail dot com Summary: No way to escape quotes for XPath Status: Bogus Type: Bug Package: *XML functions Operating System: WinXP PHP Version: 5.3.2 Assigned To: rrichards New Comment: simplest way is to use php functions for comparison, like compare htmlspecialchars escaped strings: $dom = new DOMDocument; $domstr = testdouble quote: \, single quote: '/test; $dom-loadXML($domstr); $xpath = new DOMXPath($dom); $xpath-registerNamespace(php, http://php.net/xpath;); $xpath-registerPHPFunctions(); $check_string = htmlspecialchars(double quote: \, single quote: ', ENT_QUOTES ); $q = /test[php:functionString('htmlspecialchars', ., 3) = '$check_string']; echo $q.\n; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } There is no current plan to support XPath 2.0 although possibility of supporting xpath variables in a future PHP version Previous Comments: [2010-06-18 17:05:34] pecoes at gmail dot com We seem to misunderstand each other... As long as there's only one type of quote - single or double - there's no problem, but how do I escape a string with mixed quotes? How do I quote that, so that the XPath-engine won't reject it? [2010-06-18 16:50:06] rricha...@php.net Jeez. Learn to properly escape strings then. I even gave you the proper code for your test to work. Its not a PHP bug nor a libxml2 bug so it's bogus. Regardless of the language you use you will hit escaping issues. If you really think its a bug somewhere you need to take it to the W3C. [2010-06-18 16:33:42] pecoes at gmail dot com Alright. It's not a PHP bug. So... what now? How do I deal with it in PHP? Just because PHP is innocent, doesn't mean there's no need for a fix. It's still a bug! Classifying it as bogus won't do a thing. [2010-06-18 16:22:05] rricha...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to take into account PHP string escaping too. $q = /test[text()='\']; For more complex situations with mixed quote types, its a general overall issue with XPath not a PHP bug. [2010-05-10 18:43:43] pecoes at gmail dot com Description: There seems to be no way to escape single or double quotes for XPath-Queries. given: test/test /test[text()=\] produces an error message /test[text()=\\] dito /test[text()=quot;] finds no match This is not a PHP-Bug, I suppose. It may be a bug in the libxml2. It might even be a bug in the XPath Spec itself. But regardless of where the blame lies: This is serious! How is one supposed to use user-input in an XPath, if it cannot be escaped? I found a work-around, but it's fugly: $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); function xquote ($str) { if (strpos($str, '') === FALSE) { return ''.$str.''; } if (strpos($str, ') === FALSE) { return '.$str.'; } $parts = preg_split('/()/', $str, 0, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); array_walk($parts, function ($val) { if ($val == '') $val = '\'; else $val = ''.$val.''; } ); return 'concat('.implode(',', $parts).')'; } $q = sprintf('/test[text()=%s]', xquote('')); if ($xpath-evaluate($q)-item(0)) { echo 'found'; // works! } else { echo 'not found'; } Test script: --- $dom = new DOMDocument; $dom-loadXML('test/test'); $xpath = new DOMXPath($dom); $q = '/test[text()=quot;]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } $q = '/test[text()=\\]'; if ($xpath-evaluate($q)-item(0)) { echo found\r\n; } else { echo not found\r\n; } Expected result: found found Actual result: -- not found Warning: DOMXPath::evaluate(): Invalid predicate... Warning: DOMXPath::evaluate(): Invalid expression... Fatal error: Call to a member function item() on non-object... -- Edit this bug report at http://bugs.php.net/bug.php?id=51785edit=1
Bug #51897 [Asn-Fbk]: LIBXML_NOWARNING does not suppress warnings when passed to xinclude().
Edit report at http://bugs.php.net/bug.php?id=51897edit=1 ID: 51897 Updated by: rricha...@php.net Reported by: rquadl...@php.net Summary: LIBXML_NOWARNING does not suppress warnings when passed to xinclude(). -Status: Assigned +Status: Feedback Type: Bug Package: DOM XML related Operating System: Windows XP SP3 PHP Version: 5.3.2 Assigned To: rrichards New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. please submit a test case that doesnt require phpdoc to be pulled Previous Comments: [2010-05-24 12:35:56] rquadl...@php.net Description: This issue is in relation to http://news.php.net/php.doc/969381854 Trying to standardise the documentation in relation to including class synopsis, I'm including constructor and destructor synopsis via an xinclude with an pointer and a xfallback... xi:include xpointer=xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetime')/db:refentry/db:refsec...@role='description']/desce ndant::db:destructorsynopsis[not(@role='procedural')]) xi:fallback / /xi:include As there is no destructor for datetime, the fallback is used (which is empty). All would seem to be well. The problem is that the xinclude processing generates a warning when using the online documentation editor - but not when I run this locally via phpdoc's configure. I've been supplied a test script (http://news.php.net/php.doc/969381870) which will generate the errors locally. And so to the bug. In the example the xinclude() call has no parameters. Supplying LIBXML_NOWARNING does _NOT_ suppress the warnings. To run the test script, you will need the doc-base/manual.xml file produced by running the doc-base/configure.php script (part of PHPDoc). Test script: --- ?php $doc = new DOMDocument(); $doc-load('doc-base/manual.xml', LIBXML_NOENT); var_dump($doc-xinclude(LIBXML_NOWARNING)); var_dump($doc-validate()); ? Expected result: int(-1) bool(true) Actual result: -- Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetime')/db:refentry/db:refsec...@role='description']/desce ndant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4 Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetimezone')/db:refentry/db:refsec...@role='description']/d escendant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4 Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsec...@role='description']/d escendant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4 Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsec...@role='description']/des cendant::db:destructorsynopsis[not(@role='procedural')]) in - on line 4 Warning: DOMDocument::xinclude(): XPointer evaluation failed: #xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateperiod')/db:refentry/db:refsec...@role='description']/des cendant::db:methodsynopsis[not(@role='procedural')]) in - on line 4 int(-1) bool(true) -- Edit this bug report at http://bugs.php.net/bug.php?id=51897edit=1
Bug #52012 [Opn-Bgs]: DOMDocument throws Unexpected end tag error when loading valid HTML
Edit report at http://bugs.php.net/bug.php?id=52012edit=1 ID: 52012 Updated by: rricha...@php.net Reported by: xwisdom at gmail dot com Summary: DOMDocument throws Unexpected end tag error when loading valid HTML -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: Windows XP PHP Version: 5.3.2 New Comment: Behavior is due to libxml2 handling of HTML not PHP Previous Comments: [2010-06-06 23:01:07] xwisdom at gmail dot com 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 = strongBold 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: strongBold Text/strong,Normal Text Actual result: -- Actual alert message from browser: strongBold Text,Normal Text -- Edit this bug report at http://bugs.php.net/bug.php?id=52012edit=1
Bug #46672 [Asn-Wfx]: Cloned SimpleXML Output Different
Edit report at http://bugs.php.net/bug.php?id=46672edit=1 ID: 46672 Updated by: rricha...@php.net Reported by: rfludwick at gmail dot com Summary: Cloned SimpleXML Output Different -Status: Assigned +Status: Wont fix Type: Bug Package: SimpleXML related Operating System: * PHP Version: 5.*, 6CVS (2009-04-01) Assigned To: rrichards New Comment: The asXML() method is special in regards to the document element as it treats it as a document node for simple trees. A clone of a document element is a regular element (a document can only have 1) and does not get special treatment. Patch breaks in memory tree. Either manually add the XML declaration to the clone or import to dom and clone the document and work off the new document. Previous Comments: [2010-05-27 08:10:57] m...@php.net Rob, could you have a look at this tiny patch? [2010-04-05 03:51:11] compuart dot php at gmail dot com The issue appears to be the cloned node doesn't have a document pointer as its ultimate parent. Attached patch should fix that. [2008-12-30 14:49:29] rfludwick at gmail dot com I got the same result when using the snapshot, as well as version 5.2.8. [2008-11-25 23:35:36] rfludwick at gmail dot com Description: It appears that cloning a SimpleXML object will not produce the same XML output on asXML() as the original object. The original will output the XML header and a line break after the XML while the cloned object is missing these. Reproduce code: --- ?php $simplexml = new SimpleXMLElement(root /); $simplexml-path-to-node = Zend; $simplexml_2 = clone $simplexml; echo |{$simplexml-asXML()}|\n|{$simplexml_2-asXML()}|; Expected result: |?xml version=1.0? rootpathtonodeZend/node/to/path/root | |?xml version=1.0? rootpathtonodeZend/node/to/path/root | Actual result: -- |?xml version=1.0? rootpathtonodeZend/node/to/path/root | |rootpathtonodeZend/node/to/path/root| -- Edit this bug report at http://bugs.php.net/bug.php?id=46672edit=1
Bug #51842 [Opn-Bgs]: XSLTProcessor doesn't accept dynamics DOMDocuments as XSLT
Edit report at http://bugs.php.net/bug.php?id=51842edit=1 ID: 51842 Updated by: rricha...@php.net Reported by: superruzafa at gmail dot com Summary: XSLTProcessor doesn't accept dynamics DOMDocuments as XSLT -Status: Open +Status: Bogus Type: Bug Package: XSLT related Operating System: Linux PHP Version: 5.3.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php a proper namespaced document created using the dom level 2 methods is required Previous Comments: [2010-05-17 16:58:08] superruzafa at gmail dot com Description: When trying to use XSLTProcessor::importStyleSheet() with a dynamically generated DOMDocument an error occurs. The workaround I found is save the DOMDocument for the XSLT in a string a load it again as string. Test script: --- $xml = new DOMDocument(1.0, UTF-8); $root = $xml-createElement(foo); $root-setAttribute(xmlns, http://example.com;); $xml-appendChild($root); $xslt = new DOMDocument(1.0, UTF-8); $stylesheet = $xslt-createElement(xsl:stylesheet); $stylesheet-setAttribute(version, 1.0); $stylesheet-setAttribute(xmlns:foons, http://example.com;); $stylesheet-setAttribute(xmlns:xsl, http://www.w3.org/1999/XSL/Transform;); $xslt-appendChild($stylesheet); $template = $xslt-createElement(xsl:template); $template-setAttribute(match, /); $template-appendChild($xslt-createTextNode(Hello)); $stylesheet-appendChild($template); //workaround: $xslt-loadXML($xslt-saveXML()); $xsltProc = new XSLTProcessor(); $xsltProc-importStyleSheet($xslt); echo $xsltProc-transformToDoc($xml)-saveXML(); Expected result: ?xml version=1.0? Hello Actual result: -- Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error: element xsl:stylesheet in /var/www/xslt/public_html/xslt.php on line 23 Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsltParseStylesheetProcess : document is not a stylesheet in /var/www/xslt/public_html/xslt.php on line 23 Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: No stylesheet associated to this object in /var/www/xslt/public_html/xslt.php on line 24 Fatal error: Call to a member function saveXML() on a non-object in /var/www/xslt/public_html/xslt.php on line 24 -- Edit this bug report at http://bugs.php.net/bug.php?id=51842edit=1
Bug #51753 [Bgs]: Installing PECL extensions Memcached causes segfault.
Edit report at http://bugs.php.net/bug.php?id=51753edit=1 ID: 51753 Updated by: rricha...@php.net Reported by: sa at nkvdteam dot ru Summary: Installing PECL extensions Memcached causes segfault. Status: Bogus Type: Bug Package: Unknown/Other Function Operating System: FreeBSD 7.2-RELEASE PHP Version: Irrelevant New Comment: I would first look at the threading in libmemcache. To get a better idea on what is causing the crash, you need to use a debug build of libxml2. Previous Comments: [2010-05-06 09:39:42] paj...@php.net But in any case it is not a php bug bogus. [2010-05-06 09:39:03] paj...@php.net I wonder if it is really a libxml issue, but if it is the case, to report the issue to the libxml developer would be the right way (or freebsd if it is freebsd specific). [2010-05-06 09:30:38] sa at nkvdteam dot ru No. Solution found and patch proposed. Do I need send it to FreeBSD team, or only in this bug? [2010-05-06 09:24:14] paj...@php.net Does it crash without memcached? [2010-05-06 09:16:52] sa at nkvdteam dot ru Description: After installing and enabling memcached.so extension (pecl install mecached), php segfaults on any action (e.g. php -m or php -v): [r...@node ~]# php -v PHP 5.3.2 (cli) (built: May 5 2010 20:03:50) (DEBUG) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies Segmentation fault: 11 (core dumped) Disabling all other modules (excl. memcached and session), recompiling php and libxml2, reinstalling memcached.so does not fixes it. Actual result: -- Backtrace: (gdb) bt #0 0x0008052a4840 in ?? () #1 0x000800e7e754 in xmlIsMainThread () from /usr/local/lib/libxml2.so.5 #2 0x000800e7ddb9 in __xmlLastError () from /usr/local/lib/libxml2.so.5 #3 0x000800e10d89 in xmlResetLastError () from /usr/local/lib/libxml2.so.5 #4 0x000800e179cf in xmlCleanupParser () from /usr/local/lib/libxml2.so.5 #5 0x00460078 in php_libxml_shutdown () at /usr/ports/lang/php5/work/php-5.3.2/ext/libxml/libxml.c:583 #6 0x00460593 in zm_shutdown_libxml (type=1, module_number=3) at /usr/ports/lang/php5/work/php-5.3.2/ext/libxml/libxml.c:655 #7 0x005d4906 in module_destructor (module=0x801661270) at /usr/ports/lang/php5/work/php-5.3.2/Zend/zend_API.c:2098 #8 0x005dc490 in zend_hash_apply_deleter (ht=0x8bc2e0, p=0x8016c96a0) at /usr/ports/lang/php5/work/php-5.3.2/Zend/zend_hash.c:611 #9 0x005dc60c in zend_hash_graceful_reverse_destroy (ht=0x8bc2e0) at /usr/ports/lang/php5/work/php-5.3.2/Zend/zend_hash.c:646 #10 0x005ca043 in zend_shutdown () at /usr/ports/lang/php5/work/php-5.3.2/Zend/zend.c:759 #11 0x0054c9dd in php_module_shutdown () at /usr/ports/lang/php5/work/php-5.3.2/main/main.c:2138 #12 0x006bf4f6 in main (argc=2, argv=0x7fffecb8) at /usr/ports/lang/php5/work/php-5.3.2/sapi/cli/php_cli.c:1387 -- Edit this bug report at http://bugs.php.net/bug.php?id=51753edit=1
Bug #48601 [Opn-Csd]: xpath() returns FALSE for legitimate query
Edit report at http://bugs.php.net/bug.php?id=48601edit=1 ID: 48601 Updated by: rricha...@php.net Reported by: theultramage at gmail dot com Summary: xpath() returns FALSE for legitimate query -Status: Open +Status: Closed Type: Bug Package: SimpleXML related Operating System: Windows Vista PHP Version: 6CVS-2009-06-19 (snap) -Assigned To: +Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2010-05-05 13:40:13] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=299016 Log: fix bug #48601 (xpath() returns FALSE for legitimate query) add test [2009-06-24 16:13:21] theultramage at gmail dot com From the mail of the main libxml developer (http://mail.gnome.org/archives/xml/2009-June/msg00040.html): A NULL object or an empty node set should be treated in the same way. Also There is no iterator API. So for one part, the current SimpleXML code has a bug because it does not handle the NULL value correctly (should return empty array, not FALSE). And second, there's currently no other solution. [2009-06-19 10:57:16] theultramage at gmail dot com Description: SimpleXML's xpath() implementation contains code that returns FALSE for some queries where it should be returning an empty container object. In revision 1.79 of simplexml.c (http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.78r2=1.79) the call to xmlXPathEval() was hotfixed to avoid crashing if the query errored. However, the author also added a check against retval-nodesetval, treating NULL as an error situation. I believe this was an incorrect decision. There is a scenario where 'nodesetval' will be NULL - when querying for the attribute of a non-matching element ('/foo/@attr' when there are no 'foo' nodes); in all other 'bad' queries that I tried, 'nodesetval' came initialized and containing zero nodes. So, we can see that for certain queries, simplexml will give an incorrect result. This was already pointed out on 18-dec-2005 by an user comment on the php simplexml::xpath documentation page. I have sent an inquiry to the xml mailing list (http://mail.gnome.org/archives/xml/2009-June/msg00019.html) asking for clarification, however I believe that the current logic is incorrect. I checked php's DOM module src and libxml's xpath1.c code example, and they do not consider it a problem (DOM initializes empty DOMNodeList, example sets count to 0). Alternatively, the code should not be messing with what is apparently internal structures, and instead use the API for processing, if one is available. Reproduce code: --- ?php $xml = '?xml version=1.0 encoding=utf-8?dummy/'; $db = new SimpleXMLElement($xml); if( FALSE !== $db-xpath(/foo/@attr) ) echo OK; else echo Error!; ? Expected result: xpath() should return an empty array. Actual result: -- xpath() returns FALSE. -- Edit this bug report at http://bugs.php.net/bug.php?id=48601edit=1
Bug #48511 [Asn-Bgs]: libxml_get_errors() returns an empty array but libxml_get_last_error() doesn't
Edit report at http://bugs.php.net/bug.php?id=48511edit=1 ID: 48511 Updated by: rricha...@php.net Reported by: geoffers+phpbugs at gmail dot com Summary: libxml_get_errors() returns an empty array but libxml_get_last_error() doesn't -Status: Assigned +Status: Bogus Type: Bug Package: XML Writer Operating System: Mac OS 10.5.7 PHP Version: 5.3CVS-2009-06-09 (CVS) Assigned To: rrichards New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You must set libxml_use_internal_errors(true); in order to to use the structured error handler and get a populated libxml_get_errors() return value. libxml_get_last_error() always will return last error regardless of the xml error handler used. Previous Comments: [2009-08-21 09:38:58] michael202 at gmx dot de Oh I forgot to mention that the error is present in the release version of php 5.3: PHP 5.3.0 (cli) (built: Jul 29 2009 15:03:42) [2009-08-21 09:37:18] michael202 at gmx dot de I have a similar problem: libxml_get_errors() is empty after loading a faulty XML with simplexml_load_file() BUT libxml_get_last_error() contains the last error: var_dump(libxml_get_errors()) array(0) { } var_dump(libxml_get_last_error()) object(LibXMLError)#11 solution is to use libxml_use_internal_errors: libxml_clear_errors(); // otherwise you also get all of the old errors libxml_use_internal_errors(true); other advantage is the you do not get any PHP Warning outputs and you can call simplexml_load_file without the @-operator strange though: simplexml_load_file() displays the correct error position in the PHP Warning BUT libxml_get_errors() does not contain it. [2009-06-09 17:49:07] geoffers+phpbugs at gmail dot com Description: I would expect the last member of the array returned by libxml_get_errors() to be equal to libxml_get_last_error(), but the former returns an empty array while the latter returns the expected error object. Reproduce code: --- ?php $foo = new XMLWriter(); $foo-openMemory(); $foo-startElement(\xEF\xBF\xBF); var_dump(libxml_get_last_error()); var_dump(libxml_get_errors()); var_dump(libxml_get_last_error() == end(libxml_get_errors())); Expected result: Warning: XMLWriter::startElement(): Char 0x out of allowed range in /Users/gsnedders/Desktop/test.php on line 5 Warning: XMLWriter::startElement(): Invalid Element Name in /Users/gsnedders/Desktop/test.php on line 5 object(LibXMLError)#2 (6) { [level]= int(3) [code]= int(9) [column]= int(0) [message]= string(33) Char 0x out of allowed range [file]= string(0) [line]= int(0) } array(1) { [0]= object(LibXMLError)#2 (6) { [level]= int(3) [code]= int(9) [column]= int(0) [message]= string(33) Char 0x out of allowed range [file]= string(0) [line]= int(0) } } bool(true) Actual result: -- Warning: XMLWriter::startElement(): Char 0x out of allowed range in /Users/gsnedders/Desktop/test.php on line 5 Warning: XMLWriter::startElement(): Invalid Element Name in /Users/gsnedders/Desktop/test.php on line 5 object(LibXMLError)#2 (6) { [level]= int(3) [code]= int(9) [column]= int(0) [message]= string(33) Char 0x out of allowed range [file]= string(0) [line]= int(0) } array(0) { } bool(false) -- Edit this bug report at http://bugs.php.net/bug.php?id=48511edit=1
Req #51721 [Opn-Csd]: Patch: mark DOMNodeList and DOMNamedNodeMap as Traversable
Edit report at http://bugs.php.net/bug.php?id=51721edit=1 ID: 51721 Updated by: rricha...@php.net Reported by: david dot zuelke at bitextender dot com Summary: Patch: mark DOMNodeList and DOMNamedNodeMap as Traversable -Status: Open +Status: Closed Type: Feature/Change Request Package: DOM XML related Operating System: Mac OS X 10.5.8 PHP Version: 5.3.2 -Assigned To: +Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2010-05-04 14:55:28] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=298967 Log: fix bug #51721 (mark DOMNodeList and DOMNamedNodeMap as Traversable) [2010-05-02 13:03:27] david dot zuelke at bitextender dot com Description: DOMNodeList and DOMNamedNodeMap do not implement the interface Traversable even though they can be iterated over just fine. Minor fix. Patch attached. Test script: --- ?php var_dump((new DOMNodeList) instanceof Traversable, (new DOMNamedNodeMap) instanceof Traversable); ? Expected result: bool(true) bool(true) Actual result: -- bool(false) bool(false) -- Edit this bug report at http://bugs.php.net/bug.php?id=51721edit=1
Bug #49490 [Asn-Csd]: XPath namespace prefix conflict
Edit report at http://bugs.php.net/bug.php?id=49490edit=1 ID: 49490 Updated by: rricha...@php.net Reported by: olav dot morken at uninett dot no Summary: XPath namespace prefix conflict -Status: Assigned +Status: Closed Type: Bug Package: DOM XML related Operating System: Linux (Debian) PHP Version: 5.3.0 Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. Automatic namespace registration really wasn't a good idea from the get go. Performance starts taking a hit the deeper in the tree a context node. The patch in the bug report was not used; rather a new third argument has been added to the query() and evalute() methods, which allows automatic registration of the context node to be disabled. For BC reasons auto registration is enabled by default. When auto registration is disabled and context nodes are used XPath performance will be increased. i.e. echo($xp-query('//prefix:root', null, false)-length . \n); Previous Comments: [2010-05-04 17:41:51] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=298974 Log: fix bug #49490 (XPath namespace prefix conflict) add test [2010-04-17 11:14:50] thomas at weinert dot info It looks like DOMXPath-evaluate()/DOMXPath-query() registers the namespace prefixes of the given context and overrides any definition from DOMXPath-registerNamespace(). PHP should not register any namespaces from the context or at least prefer manual registrations over automatic. Reproduce code: --- $dom = new DOMDocument(); $dom-loadXML( 'foobara:foo xmlns:a=urn:a'. 'b:bar xmlns:b=urn:b//a:foo'. '/foobar' ); $xpath = new DOMXPath($dom); //get context node and check a:foo $context = $dom-documentElement-firstChild; var_dump($context-tagName); // try to override the context node $xpath-registerNamespace('a', 'urn:b'); var_dump( $xpath-evaluate( 'descendant-or-self::a:*', $context )-item(0)-tagName ); // use a prefix not used in context $xpath-registerNamespace('prefix', 'urn:b'); var_dump( $xpath-evaluate( 'descendant-or-self::prefix:*', $context )-item(0)-tagName ); Expected result: string(5) a:foo string(5) b:bar string(5) b:bar Actual result: string(5) a:foo string(5) a:foo string(5) b:bar [2009-09-07 08:41:26] olav dot morken at uninett dot no Description: When processing an XML document with namespaces, an XPath query for a node with a different namespace but the same namespace prefix fails. This appears to be a conflict between the XPath namespaces and the document namespaces. It works if either: - The prefix in the query is replaced with a prefix that doesn't exist in the document. - If the prefix in the query matches the prefix in the document. This was tested with: - PHP 5.3 from debian experimental: 5.3.0-3 - libxml2 2.7.3.dfsg-2.1 Reproduce code: --- $doc = new DOMDocument(); $doc-loadXML('prefix:root xmlns:prefix=urn:a /'); $xp = new DOMXPath($doc); $xp-registerNamespace('prefix', 'urn:b'); echo($xp-query('//prefix:root')-length . \n); Expected result: It should not find the root node, since we ask for a node in a different prefix. I.e. it should print '0'. Actual result: -- It finds the root node, i.e. it prints '1'. -- Edit this bug report at http://bugs.php.net/bug.php?id=49490edit=1
Bug #38218 [Asn-Bgs]: php:functionString tries to access objects with their names in lowercase
Edit report at http://bugs.php.net/bug.php?id=38218edit=1 ID: 38218 Updated by: rricha...@php.net Reported by: moksinski at gmail dot com Summary: php:functionString tries to access objects with their names in lowercase -Status: Assigned +Status: Bogus Type: Bug Package: XSLT related Operating System: windows 2000 PHP Version: 6CVS-2006-07-26 (snap) Assigned To: tony2001 New Comment: No longer an issue with new trunk Previous Comments: [2006-07-26 11:59:22] tony2...@php.net Obviously, the engine is not completely ready for Unicode. I'll take a look at it. [2006-07-26 11:48:36] chr...@php.net zend_make_callable() does a lowercase in PHP 6, which it didn't before don't know, which part has to be fixed for this... [2006-07-26 11:27:39] moksinski at gmail dot com php6.0-win32-200607260830 generates the same error php5.2-win32-200607261030 - works fine [2006-07-26 08:53:22] tony2...@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip [2006-07-26 08:47:20] moksinski at gmail dot com Description: php:functionString tries to access objects with their names in lowercase. when you use autoloader to include your classes it generates fatal error because it cannot find the proper php file. Reproduce code: --- ?php //FILE AutoLoaded.php class AutoLoaded { public static function printText($text) { return $text; }} ? ?php //FILE index.php $xsl=EOSTRING xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xmlns:php=http://php.net/xsl; xsl:extension-element-prefixes=php xsl:template match=xmlxsl:value-of select=php:functionString('AutoLoaded::printText',@dummy) disable-output-escaping=yes/ /xsl:template/xsl:stylesheet EOSTRING; $xml='xml dummy=everything is ok/'; function __autoload($className) { echo $className.\n; static $classes = array('AutoLoaded'='AutoLoaded.php'); require_once($classes[$className]); } $doc = new DOMDocument('1.0','utf-8'); $doc-loadxml($xml); $xslt = new DOMDocument(); $xslt-loadxml($xsl); $proc = new XSLTProcessor(); $proc-registerPHPFunctions(); $proc-importStyleSheet($xslt); $proc-transformToXML($doc); ? Expected result: AutoLoaded Actual result: -- autoloaded Fatal error: require_once() [function.require]: Failed opening required -- Edit this bug report at http://bugs.php.net/bug.php?id=38218edit=1
Bug #48898 [Opn-Bgs]: readOuterXML() doesn't work on DTDs
Edit report at http://bugs.php.net/bug.php?id=48898edit=1 ID: 48898 Updated by: rricha...@php.net Reported by: boen dot robot at gmail dot com Summary: readOuterXML() doesn't work on DTDs -Status: Open +Status: Bogus Type: Bug Package: XML Reader Operating System: Windows Vista Ultimate x64 SP2 PHP Version: 5.3.0 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. The problem lies within libxml2. Bug is being handled there. Previous Comments: [2009-07-12 21:41:35] boen dot robot at gmail dot com Description: When reading an XML document with XMLReader, you can't use readOuterXML() to read the value of some node types, DTD being the most noticeable and disturbing one. While for readInnerXML(), the inner part may be hard to define in those node types, the outer is always clearly the whole node, and all of its descendants. If the root of the problem is in libxml, may I ask the maintainers of this extension to forward this to libxml's authors? I'm not a C user of libxml, so coming in with a runnable test case for libxml's authors would be hard. PHP runs on Apache 2.2.9 as CGI, and is the VC6 x86 Thread-safe build (just in case it matters). Reproduce code: --- ?php $reader = new XMLReader; $reader-XML('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html head titleIt works.../title /head body h1It works!/h1 /body /html'); $reader-read(); echo $reader-readOuterXML(); ? Expected result: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; Actual result: -- An empty string. -- Edit this bug report at http://bugs.php.net/bug.php?id=48898edit=1
Req #51645 [Opn-Bgs]: array_walk for DOMNodeList
Edit report at http://bugs.php.net/bug.php?id=51645edit=1 ID: 51645 Updated by: rricha...@php.net Reported by: emm980 at windowslive dot com Summary: array_walk for DOMNodeList -Status: Open +Status: Bogus Type: Feature/Change Request Package: Class/Object related Operating System: Win 7 PHP Version: 5.3.2 New Comment: Just because its iterable does not mean its an array. There are other ways to access it than foreach. Previous Comments: [2010-04-23 12:17:17] emm980 at windowslive dot com Description: An updated array_walk for DOMNodeList objects. Since these objects can be used in a foreach loop just like ordinary arrays it would be nice and a way to improve performance if it were to be possible to use then with a walker function. On the windows platform at least, array_walk is significantly faster than foreach, especially in situation where the arrays have thousands of elements or more, which I suppose is its intended use. -- Edit this bug report at http://bugs.php.net/bug.php?id=51645edit=1
Bug #51646 [Opn-Bgs]: ReflectionClass didn't show $length property from DOMNodeList
Edit report at http://bugs.php.net/bug.php?id=51646edit=1 ID: 51646 Updated by: rricha...@php.net Reported by: oleg at elifantiev dot ru Summary: ReflectionClass didn't show $length property from DOMNodeList -Status: Open +Status: Bogus Type:Bug Package: Class/Object related PHP Version: 5.2.13 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. duplicate of bug #48527 Previous Comments: [2010-04-23 14:56:09] oleg at elifantiev dot ru Description: Reflection didn't show all information on some php-internal classes (i.e. DOMNodeList). It hides some properties (i.e. DOMNodeList::$lenght) Test script: --- ? $dt = new ReflectionClass(DOMNodeList); echo $dt; ? Expected result: Class [ internal:dom iterateable class DOMNodeList ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { // want to see $length property here } - Methods [1] { Method [ internal:dom public method item ] { - Parameters [1] { Parameter #0 [ required $index ] } } } } Actual result: -- Class [ internal:dom iterateable class DOMNodeList ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [1] { Method [ internal:dom public method item ] { - Parameters [1] { Parameter #0 [ required $index ] } } } } -- Edit this bug report at http://bugs.php.net/bug.php?id=51646edit=1
Bug #51534 [Opn-Bgs]: DOMImplementation::createDocument() does not correctly append children
Edit report at http://bugs.php.net/bug.php?id=51534edit=1 ID: 51534 Updated by: rricha...@php.net Reported by: jameswithers89 at googlemail dot com Summary: DOMImplementation::createDocument() does not correctly append children -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: Fedora 12 GNU/Linux PHP Version: 5.3.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php It's appending exactly where you are telling it to Previous Comments: [2010-04-11 19:58:30] jameswithers89 at googlemail dot com The following code also produces the same error: ?php $implementation = new DOMImplementation(); $doctype = $implementation-createDocumentType('html'); // Don't create a root element... $document = $implementation-createDocument(null, null, $doctype); // ...instead create a html element and set the xmlns attribute: $html = $document-createElement('html'); $html-setAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); $document-appendChild($html); $head = $document-createElement('head'); $document-appendChild($head); echo $document-saveHTML(); [2010-04-11 19:40:38] jameswithers89 at googlemail dot com Description: The product of DOMDocument::createDocument() appends children outside of the qualified name of the document element (i.e. the root element). I am using php-5.3.2-1.fc12.i686 and php-xml-5.3.2-1.fc12.i686 installed using Yellowdog Updater, Modified Package Manager. All other DOM methods tried so far work fine. Test script: --- ?php $implementation = new DOMImplementation(); $doctype = $implementation-createDocumentType('html'); $document = $implementation-createDocument('http://www.w3.org/1999/xhtml', 'html', $doctype); $head = $document-createElement('head'); $document-appendChild($head); echo $document-saveHTML(); Expected result: !DOCTYPE html html xmlns=http://www.w3.org/1999/xhtml; head/head /html Actual result: -- !DOCTYPE html html xmlns=http://www.w3.org/1999/xhtml;/htmlhead/head -- Edit this bug report at http://bugs.php.net/bug.php?id=51534edit=1
Bug #51530 [Opn-Bgs]: DOMDocument::createElement() does not handle link correctly
Edit report at http://bugs.php.net/bug.php?id=51530edit=1 ID: 51530 Updated by: rricha...@php.net Reported by: jameswithers89 at googlemail dot com Summary: DOMDocument::createElement() does not handle link correctly -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: Fedora 12 GNU/Linux PHP Version: 5.3.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php use saveXML to produce XHTML. In regular HTML link tag has no closing tag Previous Comments: [2010-04-11 02:16:01] jameswithers89 at googlemail dot com Description: DOMDocument::createElement() does not add a closing /link tag with DOMDocument::createElement('link'). It outputs element rather than element/element. I am using php-5.3.2-1.fc12.i686 and php-xml-5.3.2-1.fc12.i686 installed using Yellowdog Updater, Modified Package Manager. All other DOM methods tried so far work fine. Test script: --- ?php $implementation = new DOMImplementation(); $document = $implementation-createDocument(null, null, $implementation-createDocumentType('html')); $html = $document-createElement('html'); $head = $document-createElement('head'); $stylesheet = $document-createElement('link'); $title = $document-createElement('title', 'Possible link error'); $body = $document-createElement('body'); $html-setAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); $stylesheet-setAttribute('href','style.css'); $stylesheet-setAttribute('rel','stylesheet'); $stylesheet-setAttribute('type','text/css'); $document-appendChild($html); $html-appendChild($head); $html-appendChild($body); $head-appendChild($stylesheet); $head-appendChild($title); echo $document-saveHTML(); Expected result: !DOCTYPE html html xmlns=http://www.w3.org/1999/xhtml; head link href=style.css rel=stylesheet type=text/css/link titlePossible link error/title /head body/body /html Actual result: -- !DOCTYPE html html xmlns=http://www.w3.org/1999/xhtml; head link href=style.css rel=stylesheet type=text/css titlePossible link error/title /head body/body /html -- Edit this bug report at http://bugs.php.net/bug.php?id=51530edit=1
Bug #50828 [Opn-Csd]: DOMNotation is not subclass of DOMNode
Edit report at http://bugs.php.net/bug.php?id=50828edit=1 ID: 50828 Updated by: rricha...@php.net Reported by: xuecan at gmail dot com Summary: DOMNotation is not subclass of DOMNode -Status: Open +Status: Closed Type: Bug Package: DOM XML related Operating System: * PHP Version: 5.*, 6 -Assigned To: +Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2010-04-09 13:34:36] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=297744 Log: fix bug #50828 (DOMNotation is not subclass of DOMNode) [2010-01-24 13:37:23] xuecan at gmail dot com Description: DOMNotation is not subclass of DOMNode but it should be. Reproduce code: --- var_dump(is_subclass_of('DOMNotation', 'DOMNode')); Expected result: bool(true) Actual result: -- bool(false) -- Edit this bug report at http://bugs.php.net/bug.php?id=50828edit=1
Bug #36795 [Opn-Bgs]: Inappropriate unterminated entity reference in DOMElement-setAttribute
Edit report at http://bugs.php.net/bug.php?id=36795edit=1 ID: 36795 Updated by: rricha...@php.net Reported by: john at carney dot id dot au Summary: Inappropriate unterminated entity reference in DOMElement-setAttribute -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: * PHP Version: 5.*, 6 New Comment: Behavior as defined by DOM specs. No warnings are issued are from either of the 2 examples in the reproduced code. addChild() method described in later reports works are defined by specs. Use the simplexml property accessors for auto escaping. Previous Comments: [2010-02-04 18:23:10] jalday at delivery dot com Still seeing this issue... $order_x-addChild('location', '1st 52nd'); gives Warning: SimpleXMLElement::addChild(): unterminated entity reference If I run it as $order_x-addChild('location', htmlspecialchars('1st 52nd')); I have no problems. [2009-10-22 16:28:09] gary dot malcolm at gmail dot com I'm running PHP 5.2.9 on Linux and this bug is still alive and well making SimpleXml absolutely inappropriate for XML communications between systems. code $safe_value = preg_replace('/(?!\w+;)/', 'amp;', $value); return $sxml-addChild($name, $safe_value); /code Is just plain wrong. I'm communicating user input directly to a bank as I can't know how the third party will parse their xml. [2008-04-03 23:15:04] rob at electronicinsight dot com A little hack to get around this bug: function safe_add_child($sxml, $name, $value) { $safe_value = preg_replace('/(?!\w+;)/', 'amp;', $value); return $sxml-addChild($name, $safe_value); } [2008-02-08 20:09:37] moshe at varien dot com PHP 5.2.4 Looks like the problem appears when there's node already exists being overwritten // works ok, doesn't require encoding: $a = simplexml_load_string('a/'); $a-b = ' ; // doesn't work, requires encoding: $a = simplexml_load_string('abtest/b/a'); $a-b = ' ; // doesn't work, always requires encoding $a-addChild('b', '); $a-addAttribute('b', '); // works ok, never requires encoding $a['b'] = '; [2007-11-27 14:03:55] oscar at cdcovers dot to I tried the workaround below and it seems to work: $xml-addChild('element', ''); $xml-element = str_replace(, amp;, value of the element); The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=36795 -- Edit this bug report at http://bugs.php.net/bug.php?id=36795edit=1
Bug #49266 [Opn-Bgs]: DOMDocument::loadHTMLFile add default Namespace even if it already exists
Edit report at http://bugs.php.net/bug.php?id=49266edit=1 ID: 49266 Updated by: rricha...@php.net Reported by: gmblar+php at gmail dot com Summary: DOMDocument::loadHTMLFile add default Namespace even if it already exists -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: MacOSX 10.5.8 PHP Version: 5.3.0 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You are mixing HTML functions (non namespace aware) when loading with XMl functions (which are namespace aware) when saving. Load it via XML functions since its xhtml. HTMl functionality is present for convenience only as DOM is meant for XMl functionality Previous Comments: [2009-08-15 12:52:13] gmblar+php at gmail dot com Description: DOMDocument::loadHTMLFile add default Namespace even if it already exists Reproduce code: --- test.html !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / titleDOM-Test/title /head body pHello World/p /body /html ?php header('Content-Type: text/plain'); $dom = new DOMDocument(); $dom-formatOutput = true; $dom-loadHTMLFile('test.html'); echo $dom-saveXML(); ? Expected result: ?xml version=1.0 encoding=UTF-8 standalone=yes? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / titleDOM-Test/title /head body pHello World/p /body /html Actual result: -- ?xml version=1.0 encoding=UTF-8 standalone=yes? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / titleDOM-Test/title /head body pHello World/p /body /html -- Edit this bug report at http://bugs.php.net/bug.php?id=49266edit=1
Bug #51417 [Opn-Bgs]: getLineNo always returns 0 when called from DOMText nodes
Edit report at http://bugs.php.net/bug.php?id=51417edit=1 ID: 51417 Updated by: rricha...@php.net Reported by: ss at contactsheet dot org Summary: getLineNo always returns 0 when called from DOMText nodes -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: linux 2.6.24 PHP Version: 5.3.2 New Comment: Not a PHP issue. You need to update libxml2 (2.7.0+) - was a bug in that library Previous Comments: [2010-03-28 07:26:22] ss at contactsheet dot org Description: The getLineNo() method exists for DOMText but doesn't work correctly; it always returns 0. Test script: --- ?php $xml = EOF foo barbaz/bar /foo EOF; $doc = new DOMDocument(); $doc-loadXML( $xml ); $text = $doc-documentElement-firstChild-nextSibling-firstChild; echo get_class( $text ) . ' : ' . $text-data . ' : ' . $text-getLineNo() . \n; ? Expected result: DOMText : baz : 2 Actual result: -- DOMText : baz : 0 -- Edit this bug report at http://bugs.php.net/bug.php?id=51417edit=1
Bug #51462 [Opn-Wfx]: Extending DOM classes work only if copy of object present
Edit report at http://bugs.php.net/bug.php?id=51462edit=1 ID: 51462 Updated by: rricha...@php.net Reported by: pahan at hubbitus dot info Summary: Extending DOM classes work only if copy of object present -Status: Open +Status: Wont fix Type: Bug Package: DOM XML related Operating System: Linux PHP Version: 5.3.2 New Comment: The tree does not maintain object state. If you are only looking for your own classtypes to be returned by the DOM methods/properties then use registerNodeClass() to register the types. Previous Comments: [2010-04-02 12:51:04] pahan at hubbitus dot info Description: Extending some DOM classes (f.e. DOMDOcument, DOMElement I think others, but not tested) work. But when such elemenmt appended to the document, additional information lost. Meantime, when copy of object saved alsewere, all work as expected. First mention of this bug and initial workaround in comment http://php.net/manual/tr/book.dom.php#80613 by ryoroxdahouse at hotmail dot com. I make automattical workaround like ( http://hinikato.blogspot.com/2009/10/domelement.html? showComment=1270202266600#c284093039037001302 ): class MyElement extends DOMElement { public function __construct($name, $value = null, $uri = null) { parent::__construct($name, $value, $uri); $GLOBALS['PHP_HACK_DOM_ELEMENT'][spl_object_hash($this)] = $this; //Note, reference is not enough :( } public function __destruct() { unset($GLOBALS['PHP_HACK_DOM_ELEMENT'][spl_object_hash($this)]); } } But as we need object copy, not just reference it requires double of memmory! Test script: --- ? class MyElement extends DOMElement{} $doc = new DOMDocument(); $doc-appendChild(new MyElement('test')); var_dump($doc-documentElement); ? Expected result: object(MyElement)#4 (0) { } Actual result: -- object(DOMElement)#4 (0) { } -- Edit this bug report at http://bugs.php.net/bug.php?id=51462edit=1
Bug #48509 [Asn-Dup]: formatOutput does not work with saveHTML
Edit report at http://bugs.php.net/bug.php?id=48509edit=1 ID: 48509 Updated by: rricha...@php.net Reported by: k...@php.net Summary: formatOutput does not work with saveHTML -Status: Assigned +Status: Duplicate Type: Bug Package: DOM XML related Operating System: Mac OS X 10.5.7 PHP Version: 5.3CVS-2009-06-09 (CVS) Assigned To: rrichards New Comment: marking this as duplicate of bug #35673 which has now been merged into the the 5_3 tree. Note that your example will not work because HTML output is only formatted when in the context of an HTML document (must have been loaded via loadHTML/File) - due to the limited HTML support in DOM extension. Previous Comments: [2010-03-06 23:23:19] fel...@php.net I got 'htmlheadtitleThis is the title/title/head/html' on 5_2, 5_3 and HEAD using saveHTML(), and using saveHTMLfile() I got: htmlhead meta http-equiv=Content-Type content=text/html; charset=UTF-8 titleThis is the title/title /head/html [2009-06-11 08:36:09] chr...@php.net Rob: I applied the patch to 5_3, but it doesn't format with libxml 2.7.3, do you know something, what's wrong here? Although, I didn't test with 2.6.23. [2009-06-10 06:49:31] chr...@php.net RIght, that never was backported to the 5_3 branch. But we're currently in a commit freeze, so I can't check it in, but will as soon as I am allowed to do it. That's the patch by the way: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/document.c? r1=1.78r2=1.79pathrev=MAINview=patch [2009-06-09 16:51:53] k...@php.net Description: While writing test cases on Oslo TestFest 2009 I just found that the $dom-formatOutput does not work with $dom-saveHTML() (even though it seems to have been resolved here: http://bugs.php.net/bug.php?id=35673) xmllint says: $ xmllint --format --html output.html !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN http://www.w3.org/TR/REC-html40/loose.dtd; htmlhead meta http-equiv=Content-Type content=text/html; charset=UTF-8 titleThis is the title/title /head/html so according to Hannes here this seems to be a bug in PHP 5.3 (may be that it's fixed i HEAD but not backported?). Reproduce code: --- ?php $doc = new DOMDocument('1.0'); $doc-formatOutput = true; $root = $doc-createElement('html'); $root = $doc-appendChild($root); $head = $doc-createElement('head'); $head = $root-appendChild($head); $title = $doc-createElement('title'); $title = $head-appendChild($title); $text = $doc-createTextNode('This is the title'); $text = $title-appendChild($text); echo $doc-saveHTML(); ? Expected result: html head titleThis is the title/title /head /html Actual result: -- htmlheadtitleThis is the title/title/head/html -- Edit this bug report at http://bugs.php.net/bug.php?id=48509edit=1
Bug #48983 [Opn-Csd]: DomDocument : saveHTMLFile wrong charset
Edit report at http://bugs.php.net/bug.php?id=48983edit=1 ID: 48983 Updated by: rricha...@php.net Reported by: php at bouchery dot fr -Summary: DomDocument : saveHTMLFile wrong charset and crash +Summary: DomDocument : saveHTMLFile wrong charset -Status: Open +Status: Closed Type: Bug Package: DOM XML related Operating System: Windows XP PHP Version: 5.3.0 -Assigned To: +Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. crash was from older libxml2 version Previous Comments: [2010-04-02 22:08:20] rricha...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=297374 Log: fix bug #48983 (DomDocument : saveHTMLFile wrong charset) [2009-07-20 16:03:31] php at bouchery dot fr Entry point php+2fa2 Create time 20/07/2009 18:00:24 Time spent in user mode 0 Days 0:0:0.31 Time spent in kernel mode 0 Days 0:0:0.78 Function Arg 1 Arg 2 Arg 3 Source php5ts!DllMain+c2 PHP5TS!DLLMAIN+C2WARNING - DebugDiag was not able to locate debug symbols for php5ts.dll, so the information below may be incomplete. In php__PID__1304__Date__07_20_2009__Time_06_00_34PM__618__Second_Chance_ Exception_C005.dmp the assembly instruction at php5ts!DllMain+c2 in C:\bin\php-5.3.0\php5ts.dll from The PHP Group has caused an access violation exception (0xC005) when trying to read from memory location 0x64756f70 on thread 0 Module Information Image Name: C:\bin\php-5.3.0\php5ts.dll Symbol Type: Export Base address: 0x1000 Time Stamp: Mon Jun 29 22:53:15 2009 Checksum: 0x00579fbc Comments: COM DLL: False Company Name: The PHP Group ISAPIExtension: False File Description: PHP Script Interpreter ISAPIFilter: False File Version: 5.3.0 Managed DLL: False Internal Name: PHP Script Interpreter VB DLL: False Legal Copyright: Copyright © 1997-2009 The PHP Group Loaded Image Name: php5ts.dll Legal Trademarks: PHP Mapped Image Name: Original filename: php5ts.dll Module name: php5ts Private Build: Single Threaded: False Product Name: PHP Module Size: 5,61 MBytes Product Version: 5.3.0 Symbol File Name: php5ts.dll Special Build: ) [2009-07-20 14:53:16] j...@php.net Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php for *NIX and http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32 Once you have generated a backtrace, please submit it to this bug report and change the status back to Open. Thank you for helping us make PHP better. [2009-07-20 09:44:27] php at bouchery dot fr Description: When using DomDocument to generate HTML. If I'm trying to add the content-type, and generate a file with saveHTMLfile, PHP crash and charset is not correctly defined (Always UTF-8). With saveHTML, it works fine. Reproduce code: --- ?php $doc = new DOMDocument('1.0','iso-8859-1'); $doc-formatOutput = true; $root = $doc-createElement('html'); $root = $doc-appendChild($root); $head = $doc-createElement('head'); $head = $root-appendChild($head); $title = $doc-createElement('title'); $title = $head-appendChild($title); $text = $doc-createTextNode('This is the title'); $text = $title-appendChild($text); $meta = $doc-createElement('meta'); $meta = $head-appendChild($meta); $meta-setAttribute('http-equiv', 'Content-Type'); $meta-setAttribute('content', 'text/html; charset=ISO-8859-1'); echo $doc-saveHTML(); $doc-saveHTMLFile('result.html'); ? Expected result: No crash, output is : htmlhead titleThis is the title/title meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 /head/html And result.html must contains : htmlhead titleThis is the title/title meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 /head/html Actual result: -- PHP process crash Output : htmlhead titleThis is the title/title meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 /head/html result.html htmlhead meta http-equiv=Content-Type content
Bug #51325 [Opn-Bgs]: DOMDocument::load() UTF-8 limitation
Edit report at http://bugs.php.net/bug.php?id=51325edit=1 ID: 51325 Updated by: rricha...@php.net Reported by: jean dot tiberghien at quetzalx dot fr Summary: DOMDocument::load() UTF-8 limitation -Status: Open +Status: Bogus Type: Bug Package: DOM XML related Operating System: Windows WAMP + LAMP(?) PHP Version: 5.3.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You are passing an XML document which clearly states it is UTF-8 via the xml declaration ?xml version=1.0 encoding=UTF-8? so DOM expects UTF-8. Set it to the proper encoding. Already a feature request to pass an encoding when *not* specified by encoding param in xml declaration. Previous Comments: [2010-03-18 18:09:31] jean dot tiberghien at quetzalx dot fr Description: The DOMDocument::load() function ONLY loads UTF-8 encoded files. Ex: 'article.php' contains : $xmlDoc = new DOMDocument(); $page = 'article.xsl'; $xmlDoc-load($page); $xmlDoc-load('cours.xml'); Let's consider 'article.xsl' contains '... Précédent ...' (not pure ASCII chars) If the content of 'article.xsl' is iso-8859-1 encoded, the subsequent error appears (same if 'cours.xml' is iso-8859-1 encoded): DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE9 0x62 0x75 0x74 in file:///C:/wamp/www/xsl2/article.xsl, line: 71 in C:\wamp\www\xsl2\article.php on line 13 So, it's imperative to UTF-8 encode 'cours.xml' and 'article.xsl'. Of course $page = utf8_encode($page); ... is of no use, because the 'utf8_encode' only operates on the string 'article.xsl', and not on the file content !. CONCLUSION : It's not really a BUG in the -load() function. But it would be really important to have a supplementary optional parameter, indicating the encoding of the incoming file: -Desired improvment --- Add an optional parameter describing the $file actual encoding: $xmlDoc-load($page, 'iso-8859-1'); DOMDocument::load( string $file [, string $encoding]) The $encoding optional parameter thus would be useful to describe the actual $file encoding (if not UTF-8). --- END -- Test script: --- [test.php] ?php $xmlDoc = new DOMDocument(); $xmlDoc-load(cours.xml); ? [cours.xml] (no matter the line encoding... The problem is caused by the 'é' from 'éclair'...) ?xml version=1.0 encoding=UTF-8? root chapitre titre=Titre du chapitre 1 partie titre=Titre de la partie 1 Texte éclair /partie /chapitre /root (displays): Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xE9 0x63 0x6C 0x61 in file:///C:/wamp/www/xsl2/cours.xml, line: 5 in C:\wamp\www\xsl2\test.php on line 3 -- Edit this bug report at http://bugs.php.net/bug.php?id=51325edit=1
Bug #51235 [Opn-Fbk]: getElementsByTagName always return an empty list
Edit report at http://bugs.php.net/bug.php?id=51235edit=1 ID: 51235 Updated by: rricha...@php.net Reported by: marsala dot marco at fastwebnet dot it Summary: getElementsByTagName always return an empty list -Status: Open +Status: Feedback Type:Bug Package: DOM XML related PHP Version: 5.3.2 New Comment: You sure no errors or warnings being thrown that aren't being shown? The example works fine for me using 5.3.2 and latests libxml2. Previous Comments: [2010-03-08 13:27:47] marsala dot marco at fastwebnet dot it Description: $document = new DOMDocument()-load(...); $document-getElementsByTagName(root element name) works (returns list with one element). getElementsByTagName(non root element name) always return an empty list. Examples on notes and on the web (some examples claimed to be working are prior the 5.3.2) are all not working. Tested on LAMP server PHP 5.2.8 AND on XAMPPLite WAMP PHP 5.3.1, both not working. Test script: --- $doc = new DOMDocument(); $doc-load('__xml/faq.xml'); $faqs = $doc-getElementsByTagName(faq); echo $faqs-length; // always 0 __xml/faq.xml is: ?xml version=1.0 encoding=iso-8859-1? faqs faq domandadomanda1/domanda rispostarisposta1/risposta /faq faq domandadomanda2/domanda rispostarisposta2/risposta /faq faq domandadomanda3/domanda rispostarisposta3/risposta /faq /faqs -- Edit this bug report at http://bugs.php.net/bug.php?id=51235edit=1
#47532 [Opn-WFx]: DOMAttribute value getter and setter do not escape equally
ID: 47532 Updated by: rricha...@php.net Reported By: sgunderson at bigfoot dot com -Status: Open +Status: Wont fix Bug Type: DOM XML related Operating System: Debian PHP Version: 5.3CVS-2009-02-28 (snap) New Comment: Changing this would break some long standing BC. The problem is really in setting the attribute value. The workaround for this is to use something like htmlspecialchars when setting a DOMAttr-value using another DOMAttr-value Previous Comments: [2009-02-28 16:13:54] sgunderson at bigfoot dot com Description: When you fetch the value field of a DOMAttribute, it seems to unescape any HTML (or perhaps XML?) entities present. However, when you set it, it does not get escaped. In other words, if you do $attr-value = $attr-value (which really should be a no-op!) as in the example below, you will get errors if it happened to contain amp;. Verified with PHP 5.2.6 and 5.3.0 snap (2008-02-28). Reproduce code: --- ?php $doc = new DOMDocument; $doc-loadXML('htmlelement //html'); $elem = $doc-documentElement-firstChild; $attr = $doc-createAttribute(foo); $attr-value = fooamp;bar; $attr-value = $attr-value; $elem-appendChild($attr); print $doc-saveXML(); ? Expected result: ?xml version=1.0? htmlelement foo=fooamp;bar//html Actual result: -- Warning: main(): unterminated entity reference bar in /home/sesse/test3.php on line 8 ?xml version=1.0? htmlelement foo=foo//html -- Edit this bug report at http://bugs.php.net/?id=47532edit=1
#49282 [Opn-Bgs]: importNode() looses namespaceURI value
ID: 49282 Updated by: rricha...@php.net Reported By: daniel at webdevelopers dot cz -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Ubuntu 2.6.21 i686 PHP Version: 5.3.0 New Comment: This was a bug in the libxml2 library and fixed there. Will be in the 2.7.7 release Previous Comments: [2009-08-17 16:53:24] daniel at webdevelopers dot cz Description: libxml 2.6.31 When importing previously removed element into the new document the namespaceURI is not preserved. It is preserved only if the @xmlns declaration attribute is present on the element itself. Does not work if it was declared on former ancestor. Reproduce code: --- $rcpt=new DOMDocument; $rcpt-loadXML(rcpt/rcpt); // XMLNS on parent $dnr1=new DOMDocument; $dnr1-loadXML(dnr xmlns:sys='http://www.1stomni.com/spire'sys:donate//dnr); // XMLNS on element $dnr2=new DOMDocument; $dnr2-loadXML(dnrsys:donate xmlns:sys='http://www.1stomni.com/spire'//dnr); getGift($rcpt, $dnr1-documentElement-removeChild($dnr1-documentElement-firstChild)); getGift($rcpt, $dnr2-documentElement-removeChild($dnr2-documentElement-firstChild)); function getGift($dom, $gift) { echo before: \$gift-namespaceURI\; after: \.$dom-documentElement-appendChild($dom-importNode($gift))-namespaceURI.\\n; } Expected result: before: http://www.1stomni.com/spire;; after: http://www.1stomni.com/spire; before: http://www.1stomni.com/spire;; after: http://www.1stomni.com/spire; Actual result: -- before: http://www.1stomni.com/spire;; after: before: http://www.1stomni.com/spire;; after: http://www.1stomni.com/spire; -- Edit this bug report at http://bugs.php.net/?id=49282edit=1
#50767 [Asn-Fbk]: XMLReader does not accept zip stream
ID: 50767 Updated by: rricha...@php.net Reported By: jhgundersen at gmail dot com -Status: Assigned +Status: Feedback Bug Type: Streams related Operating System: Ubuntu 9.10 PHP Version: 5.3.1 Assigned To: rrichards New Comment: Check all your error logs to see if anything unexpected happened. I also cannot reproduce this. Have tried it on 3 different OSs and it has worked properly on each Previous Comments: [2010-01-21 10:07:51] j...@php.net Rob, feedback was given. [2010-01-19 12:22:18] jhgundersen at gmail dot com phpinfo gives me: libxml Version 2.7.3 [2010-01-19 12:05:14] rricha...@php.net What version of libxml2 are you using? [2010-01-19 09:36:31] paj...@php.net Richard, can you take a look please? Maybe it will ring a bell? libxml stream bug or smtg else, but I can't reproduce it here, on unix (ubuntu 9.10) or win. [2010-01-19 08:27:02] jhgundersen at gmail dot com And it happens with every zip file I've tried. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/50767 -- Edit this bug report at http://bugs.php.net/?id=50767edit=1
#50805 [Opn-Bgs]: simplexml_load_string not finding any data
ID: 50805 Updated by: rricha...@php.net Reported By: okycastro at gmail dot com -Status: Open +Status: Bogus Bug Type: *XML functions Operating System: windows vista PHP Version: 5.2.12 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to use correct XPath expressions Previous Comments: [2010-01-20 15:45:52] okycastro at gmail dot com Description: simplexml_load_string not producing the expected results Reproduce code: --- $xml = XML ?xml version=1.0 encoding=utf-8? soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; soapenv:Body ns1:createBanResponse soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; xmlns:ns1=http://ws.interfaces.sessions.APILink.amdocs; createBanReturn href=#id0 / /ns1:createBanResponse multiRef id=id0 soapenc:root=0 soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; xsi:type=ns2:OutCreateBanInfo xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/; xmlns:ns2=http://io.datainfo.APILink.amdocs; ban xsi:type=xsd:int688666259/ban /multiRef /soapenv:Body /soapenv:Envelope XML; $root = simplexml_load_string($xml); var_dump($root); //EMPTY $result = $root-xpath(ban);//EMPTY print_r($result);//EMPTY Expected result: I expected some data from the xml. For example xpath should return 688666259. I use simplexml_load_string many time and never have problems. I never used it with an xml with so many attributes. Actual result: -- Array ( ) object(SimpleXMLElement)#1 (0) { } -- Edit this bug report at http://bugs.php.net/?id=50805edit=1
#50767 [Asn-Fbk]: XMLReader does not accept zip stream
ID: 50767 Updated by: rricha...@php.net Reported By: jhgundersen at gmail dot com -Status: Assigned +Status: Feedback Bug Type: Streams related Operating System: Ubuntu 9.10 PHP Version: 5.3.1 Assigned To: rrichards New Comment: What version of libxml2 are you using? Previous Comments: [2010-01-19 09:36:31] paj...@php.net Richard, can you take a look please? Maybe it will ring a bell? libxml stream bug or smtg else, but I can't reproduce it here, on unix (ubuntu 9.10) or win. [2010-01-19 08:27:02] jhgundersen at gmail dot com And it happens with every zip file I've tried. [2010-01-19 08:21:00] jhgundersen at gmail dot com the zip extension is loaded: Zip: enabled Extension Version: $Id: php_zip.c,v 1.1.2.38.2.29 2009/02/24 23:55:14 iliaa Exp $ Zip version:1.9.1 Libzip version: 0.9.0 I totally agree that it is weird that the zip protocol seems to be working everywhere else but with xmlreader. [2010-01-18 17:32:53] paj...@php.net It works just fine here. It is rather expected as both file_get_contents and xmlreader use the exact same code to read a zip entry. Please provide a link to the archive you use for this test or double check that you actually load the zip extension for this test. [2010-01-15 15:19:49] jhgundersen at gmail dot com Zip stream works with file_get_contents, I can open the test.xml with zip archive The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/50767 -- Edit this bug report at http://bugs.php.net/?id=50767edit=1
#49463 [Opn-Csd]: setAttributeNS fails setting default namespace
ID: 49463 Updated by: rricha...@php.net -Summary: setAttributeNS(http://www.w3.org/2000/xmlns/,xmlns,blah;) produces error Reported By: himajin10 at gmail dot com -Status: Open +Status: Closed Bug Type: DOM XML related Operating System: Windows XP SP3 PHP Version: 6SVN-2009-09-04 (snap) 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2010-01-15 21:29:57] s...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionrevision=293597 Log: fix bug #49463 (setAttributeNS fails setting default namespace) add test [2009-09-04 01:48:10] himajin10 at gmail dot com Description: STEPS TO REPRODUCE: 1.run the Reproduce Code 2.read the DOM Core spec from 'if the qualifiedName or its prefix is xmlns' http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-ElSetAttrNS Reproduce code: --- ?php $doc = new DOMDocument('1.0', 'utf-8'); $root = $doc-createElementNS('http://purl.org/rss/1.0/','rdf:RDF'); $root-setAttributeNS(http://www.w3.org/2000/xmlns/,xmlns,http://purl.org/rss/1.0/; ); ? Expected result: No Error. Actual result: -- Fatal error: Uncaught exception 'DOMException' with message 'Namespace Error' in C:\Environment\Users\WWW\OKWave\Q5261193\Q5261193-2.php06:5 Stack trace: #0 C:\Environment\Users\WWW\OKWave\Q5261193\Q5261193-2.php06(5): DOMElement-setAttributeNS('http://www.w3.o...', 'xmlns', 'http://purl.org...') #1 {main} thrown in C:\Environment\Users\WWW\OKWave\Q5261193\Q5261193-2.php06 on line 5 -- Edit this bug report at http://bugs.php.net/?id=49463edit=1
#50661 [Asn-Csd]: DOMDocument::loadXML does not allow UTF-16
ID: 50661 Updated by: rricha...@php.net Reported By: geoffers+phpbugs at gmail dot com -Status: Assigned +Status: Closed Bug Type: DOM XML related Operating System: Mac OS 10.5.8 PHP Version: 5.3SVN-2010-01-04 (SVN) Assigned To: rrichards 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2010-01-06 13:13:18] s...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionrevision=293176 Log: fix bug #50661 (DOMDocument::loadXML does not allow UTF-16) add test [2010-01-04 23:16:49] rricha...@php.net Assign to self [2010-01-04 20:58:36] geoffers+phpbugs at gmail dot com Description: DOMDocument::loadXML() does not support UTF-16 encoded XML. This breaks the XML spec which says, All XML processors MUST accept the UTF-8 and UTF-16 encodings of Unicode. As such, DOMDocument::loadXML() is not a conformant XML processor. XMLReader supports this fine, which suggests something is wrong in the use of the libxml2 API. Reproduce code: --- ?php $data = \xFE\xFF\x00\x3C\x00\x66\x00\x6F\x00\x6F\x00\x2F\x00\x3E; $dom = new DOMDocument(); $dom-loadXML($data); echo $dom-saveXML(); Expected result: ?xml version=1.0? foo/ Actual result: -- PHP Warning: DOMDocument::loadXML(): Start tag expected, '' not found in Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5 Warning: DOMDocument::loadXML(): Start tag expected, '' not found in Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5 ?xml version=1.0? -- Edit this bug report at http://bugs.php.net/?id=50661edit=1
#50661 [Opn]: DOMDocument::loadXML does not allow UTF-16
ID: 50661 Updated by: rricha...@php.net Reported By: geoffers+phpbugs at gmail dot com Status: Open Bug Type: DOM XML related Operating System: Mac OS 10.5.8 PHP Version: 5.3SVN-2010-01-04 (SVN) -Assigned To: +Assigned To: rrichards New Comment: Assign to self Previous Comments: [2010-01-04 20:58:36] geoffers+phpbugs at gmail dot com Description: DOMDocument::loadXML() does not support UTF-16 encoded XML. This breaks the XML spec which says, All XML processors MUST accept the UTF-8 and UTF-16 encodings of Unicode. As such, DOMDocument::loadXML() is not a conformant XML processor. XMLReader supports this fine, which suggests something is wrong in the use of the libxml2 API. Reproduce code: --- ?php $data = \xFE\xFF\x00\x3C\x00\x66\x00\x6F\x00\x6F\x00\x2F\x00\x3E; $dom = new DOMDocument(); $dom-loadXML($data); echo $dom-saveXML(); Expected result: ?xml version=1.0? foo/ Actual result: -- PHP Warning: DOMDocument::loadXML(): Start tag expected, '' not found in Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5 Warning: DOMDocument::loadXML(): Start tag expected, '' not found in Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5 ?xml version=1.0? -- Edit this bug report at http://bugs.php.net/?id=50661edit=1
#50545 [Opn-Fbk]: entities being dropped, schma validation fails
ID: 50545 Updated by: rricha...@php.net Reported By: aclark at wayfm dot com -Status: Open +Status: Feedback Bug Type: DOM XML related Operating System: Gentoo Linux PHP Version: 5.2.12 New Comment: Try upgrading libxml. Versions 2.7.0 - 2.7.2 had broken some entity handling and this appears to be that Previous Comments: [2009-12-22 16:10:17] aclark at wayfm dot com Compiled against libxml2-2.7.2-r2. [2009-12-22 09:11:11] j...@php.net 1. What libxml version is PHP compiled with? (check from phpinfo()..) 2. Your reproducing script has some problems since it's not possible to copy'n'paste it and just run it.. [2009-12-21 17:45:51] aclark at wayfm dot com Description: After a recent PHP upgrade (to 5.2.11-r1), some existing code on a few of my sites suddenly broke. In both instances, it's XML-related PHP code that silently and completely drops html entities from XML code. In one instance, it's an RSS feed. content:encodedlt;pgt;Lorem... becomes content:encodedpLorem... The (newly) offending code contains the xml_parse_into_struct function. In the other, it's a CDATA section of an XML-RPC ping. Same problem. The entity-escaped tags are preserved, but without the surrounding lt and gt entities, rendering the payload useless. This code uses DOMDocument::LoadXML and schemaValidate Searching a bit turned up the desiccated carcass of bug #35271, but nothing recent that I could find. Downgraded to PHP 5.2.9-r2. Same problem Reproduce code: --- libxml_use_internal_errors(true); $xdoc= new DomDocument; $xml=$params[1]; if (!$xml) { xmlrpc_error(10, No payload detected.); } $xmlschema='payload2.xsd'; $xdoc-LoadXML($xml); if ($xdoc-schemaValidate($xmlschema)) { Expected result: $xml (payload from incoming XML-RPC ping) is successfully validated against the schema doc), schemaValidate if statement is true, code inside is executed. Actual result: -- Schema validation fails with The document has no document element. A dump of the payload reveals that lt and gt entities have been stripped from the payload: tag attr=truetag attr=10046tag /tagtagTag Contents/tagtag Tag Contents/tag/tag/tag //tag schemaValidate if statement is false, else code (omitted) is executed, returning aforementioned error to RPC client. -- Edit this bug report at http://bugs.php.net/?id=50545edit=1
#50545 [Opn-Bgs]: entities being dropped, schma validation fails
ID: 50545 Updated by: rricha...@php.net Reported By: aclark at wayfm dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Gentoo Linux PHP Version: 5.2.12 New Comment: Dupe of bug #45996 Previous Comments: [2009-12-22 17:26:54] aclark at wayfm dot com Did a search based on rrichards' comment and found bug #45996. Upgraded to libxml2-2.7.3-r2, built php-5.2.11-r1 against it, and restarted apache. Both problems have been resolved. Thanks for your help and sorry to post a non-bug. Should this be closed as a duplicate of bug #45996? [2009-12-22 16:45:35] rricha...@php.net Try upgrading libxml. Versions 2.7.0 - 2.7.2 had broken some entity handling and this appears to be that [2009-12-22 16:10:17] aclark at wayfm dot com Compiled against libxml2-2.7.2-r2. [2009-12-22 09:11:11] j...@php.net 1. What libxml version is PHP compiled with? (check from phpinfo()..) 2. Your reproducing script has some problems since it's not possible to copy'n'paste it and just run it.. [2009-12-21 17:45:51] aclark at wayfm dot com Description: After a recent PHP upgrade (to 5.2.11-r1), some existing code on a few of my sites suddenly broke. In both instances, it's XML-related PHP code that silently and completely drops html entities from XML code. In one instance, it's an RSS feed. content:encodedlt;pgt;Lorem... becomes content:encodedpLorem... The (newly) offending code contains the xml_parse_into_struct function. In the other, it's a CDATA section of an XML-RPC ping. Same problem. The entity-escaped tags are preserved, but without the surrounding lt and gt entities, rendering the payload useless. This code uses DOMDocument::LoadXML and schemaValidate Searching a bit turned up the desiccated carcass of bug #35271, but nothing recent that I could find. Downgraded to PHP 5.2.9-r2. Same problem Reproduce code: --- libxml_use_internal_errors(true); $xdoc= new DomDocument; $xml=$params[1]; if (!$xml) { xmlrpc_error(10, No payload detected.); } $xmlschema='payload2.xsd'; $xdoc-LoadXML($xml); if ($xdoc-schemaValidate($xmlschema)) { Expected result: $xml (payload from incoming XML-RPC ping) is successfully validated against the schema doc), schemaValidate if statement is true, code inside is executed. Actual result: -- Schema validation fails with The document has no document element. A dump of the payload reveals that lt and gt entities have been stripped from the payload: tag attr=truetag attr=10046tag /tagtagTag Contents/tagtag Tag Contents/tag/tag/tag //tag schemaValidate if statement is false, else code (omitted) is executed, returning aforementioned error to RPC client. -- Edit this bug report at http://bugs.php.net/?id=50545edit=1
#50390 [Opn-Fbk]: DomXPath fails to find data
ID: 50390 Updated by: rricha...@php.net Reported By: liviu dot macoviciuc at gmail dot com -Status: Open +Status: Feedback Bug Type: DOM XML related Operating System: windows xp PHP Version: 5.2.11 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: [2009-12-05 10:42:55] liviu dot macoviciuc at gmail dot com Description: I have an html file and I try to locate an element with Xpath. Results : 0 I rewrote it in C with libxml2 Results :1 CORRECT So the problem is in php I can provide the source code for all files It is not my first bad experience with xpath in php Another time, it used to return the right results, but 10 times -- Edit this bug report at http://bugs.php.net/?id=50390edit=1
#50390 [Opn-Bgs]: DomXPath fails to find data
ID: 50390 Updated by: rricha...@php.net Reported By: liviu dot macoviciuc at gmail dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: windows xp PHP Version: 5.2.11 New Comment: Works fine if you fix your script. You arent even providing valid data to load into a DOM. Previous Comments: [2009-12-05 10:59:29] liviu dot macoviciuc at gmail dot com http://www.storage.to/get/lgBv4d7m/Desktop.rar All the code [2009-12-05 10:49:39] rricha...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. [2009-12-05 10:42:55] liviu dot macoviciuc at gmail dot com Description: I have an html file and I try to locate an element with Xpath. Results : 0 I rewrote it in C with libxml2 Results :1 CORRECT So the problem is in php I can provide the source code for all files It is not my first bad experience with xpath in php Another time, it used to return the right results, but 10 times -- Edit this bug report at http://bugs.php.net/?id=50390edit=1
#47848 [Opn-Csd]: importNode doesn't preserve attribute namespaces
ID: 47848 Updated by: rricha...@php.net Reported By: robin2008 at altruists dot org -Status: Open +Status: Closed Bug Type: DOM XML related Operating System: Ubuntu PHP Version: 5.2.9 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2009-12-03 20:19:38] s...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionrevision=291669 Log: fix bug #47848 (importNode doesn't preserve attribute namespaces) add tests [2009-03-31 11:29:03] robin2008 at altruists dot org Description: I was expecting importNode to preserve attribute namespaces. It doesn't Reproduce code: --- ?php // PHP 5.2.* namespace bug - importNode doesn't preserve attribute namespaces $aDOM= new DOMDocument(); $aDOM-appendChild($aDOM-createElementNS('http://friend2friend.net/','f2f:a')); echo 'DOM to add into is '.$aDOM-saveXML().chr(13); $fromdom= DOMDocument::loadXML('data xmlns:ai= http://altruists.org ai:attr=namespaced /'); echo 'Dom to import from is'.$fromdom-saveXML().chr(13); $attr= $fromdom-firstChild-attributes-item(0); $aDOM-documentElement-appendChild($aDOM-importNode($attr)); echo 'Result is '.$aDOM-saveXML(); // The following script gets round this bug function importAttrNS($targetNode, $attr) { // Last modified 2009-01-26 Imports an attribute without losing the NS, if present if ($attr-prefix=='') $targetNode-appendChild($targetNode-ownerDocument-importNode($attr)); else $targetNode-setAttributeNS($attr-lookupNamespaceURI($attr-prefix), $attr-prefix.':'.$attr-name, $attr-value); } ? Expected result: The imported attribute should keep its namespace. Actual result: -- The imported attribute becomes unnamespaced. -- Edit this bug report at http://bugs.php.net/?id=47848edit=1
#50325 [Opn-Bgs]: DOMXPath can not find anything without the namespace specified
ID: 50325 Updated by: rricha...@php.net Reported By: winner5 at interia dot pl -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Linux PHP Version: 5.2.11 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Default namespaces must always be registered. A prefix is required to use namespaces in xpath queries. Not a PHP issue Previous Comments: [2009-11-29 14:40:11] winner5 at interia dot pl Description: DOMXPath do not find anything, like it should due to php.net online guide, it requires to registerNamespace in DOMXPath Reproduce code: --- ?php $dom = new DOMDocument(); $dom-loadXML('?xml version=1.0 encoding=utf-8 standalone=no?!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd;html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en dir=ltrheadtitleTitle/title/headbodydivdiv id=readpThis/p/div/div/body/html'); header('Content-Type: application/xhtml+xml; charset=utf-8'); $xpath = new DOMXPath($dom); $nodelist = $xpath-query('/html/body/div/d...@id=\'read\'][1]'); $root = $nodelist-item(0); $root-appendChild($dom-createElement('p', $root-nodeName)); print($dom-saveXML()); ? Expected result: Just the same as: ?php $dom = new DOMDocument(); $dom-loadXML('?xml version=1.0 encoding=utf-8 standalone=no?!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd;html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en dir=ltrheadtitleTitle/title/headbodydivdiv id=readpThis/p/div/div/body/html'); header('Content-Type: application/xhtml+xml; charset=utf-8'); $xpath = new DOMXPath($dom); $xpath-registerNamespace('x', $dom-documentElement-namespaceURI); $nodelist = $xpath-query('/x:html/x:body/x:div/x:d...@id=\'read\'][1]'); $root = $nodelist-item(0); $root-appendChild($dom-createElement('p', $root-nodeName)); print($dom-saveXML()); ? Actual result: -- Fatal error: Call to a member function appendChild() on a non-object in ./index.php on line 10 -- Edit this bug report at http://bugs.php.net/?id=50325edit=1
#50156 [Opn-Bgs]: Empty element should also return END_ELEMENT
ID: 50156 Updated by: rricha...@php.net Reported By: edwin at bitstorm dot org -Status: Open +Status: Bogus Bug Type: XML Reader Operating System: Ubuntu 9.04 PHP Version: 5.2SVN-2009-11-12 (SVN) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Behavior is based on the MS C# implementation. END_ELEMENT is not generated for empty elements. Previous Comments: [2009-11-24 16:14:57] edwin at bitstorm dot org Turns out I can use the isEmptyElement-property to find out when dealing with an a/-element. This is a bit unfortunate, because, for example, SAX (the mother of all xml-readers?) does not use this mechnism and works as I would expect. It's just how libxml seems to work, so it should probably not be marked as a PHP-bug. This bug can be closed: not a bug... :-/ A little parsing example in the documentation might be a very good idea, though. [2009-11-12 21:14:17] edwin at bitstorm dot org XML-parser used is libxml 2.7.3 . [2009-11-12 21:02:52] edwin at bitstorm dot org ?php // Source code for bug #50156 // The following code will output the text below, which // is not what you expect when you see the xml. // // Barcode is not a child of Type, but how can you know? // // Titles // Titles // Titles - Title // Titles - Title // Titles - Title - ID // Titles - Title - ID // Titles - Title // Titles - Title // Titles - Title - Type // Titles - Title - Type // Titles - Title - Type - Barcode // Titles - Title - Type // Titles - Title - Type // Titles - Title // Titles - Title // Titles $xml = Titles Title ID429/ID Type/ Barcode/Barcode /Title /Titles ; $expected = Titles Titles Titles - Title Titles - Title Titles - Title - ID Titles - Title - ID Titles - Title Titles - Title Titles - Title - Type Titles - Title Titles - Title Titles - Title - Barcode Titles - Title Titles - Title Titles Titles ; $reader = new XMLReader(); $reader-xml($xml); $actual = ''; // Make a stack for every element $stack = array(); while ($reader-read()) { switch($reader-nodeType) { case XMLReader::ELEMENT: array_push($stack, $reader-name); break; case XMLReader::END_ELEMENT: array_pop($stack); break; } $actual .= join(' - ', $stack).\n; } // Clean up and make it OS-agnostic $expected = preg_replace('/\\r/', '', trim($expected)); $actual = preg_replace('/\\r/', '', trim($actual)); // Print result echo h3Expected/h3\n; echo pre$expected/pre\n; echo h3Actual/h3\n; echo pre$actual/pre\n; // Test it if ($expected == $actual) { echo strongGood/strong; } else { echo strongNot good/strong; } ? [2009-11-12 13:48:14] edwin at bitstorm dot org Description: Element a/a returns twice, one for XMLReader::ELEMENT and one for XMLReader::END_ELEMENT. Element a/ returns once, for XMLReader::ELEMENT. That should return a XMLReader::END_ELEMENT too, because that's implicit. Problem is that now you can't distinguish between ab and a/b and that's a bug. Reproduce code: --- $reader = new XMLReader(); $reader-open($file); echo table\n; while ($reader-read()) { echo trtd.$reader-nodeType./tdtd.$node = $reader-name./tdtd.$reader-value./td/tr\n; } echo /table\n; Input: Titles Title ID429/ID Type / Barcode /Barcode Expected result: 1 Titles 14 #text 1 Title 14 #text 1 ID 3 #text 429 15 ID 14 #text 1 Type 14 #text 15 Type 14 #text 1 Barcode 14 #text 15 Barcode 14 #text Actual result: -- 1 Titles 14 #text 1 Title 14 #text 1 ID 3 #text 429 15 ID 14 #text 1 Type 14 #text 1 Barcode 14 #text 15 Barcode 14 #text -- Edit this bug report at http://bugs.php.net/?id=50156edit=1
#50201 [Opn-Fbk]: Error validating xml with namespace against xsd
ID: 50201 Updated by: rricha...@php.net Reported By: a dot testa at wifisolution dot it -Status: Open +Status: Feedback Bug Type: DOM XML related Operating System: linux PHP Version: 5.2.11 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: [2009-11-17 09:48:59] a dot testa at wifisolution dot it Description: php fails to validate a xml against a xsd. the xml is build with the DOM interface. the function schemaValidate returns true if i load the document from a file but not with the same document created on the fly. as workaround i can create the document, write it on a file, load againt and then validate. -- Edit this bug report at http://bugs.php.net/?id=50201edit=1
#50201 [Opn-Bgs]: Error validating xml with namespace against xsd
ID: 50201 Updated by: rricha...@php.net Reported By: a dot testa at wifisolution dot it -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: linux PHP Version: 5.2.11 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php createElement is level 1 non-namespace aware method. Use level 2 createElementNS method for all elements and create them in the urn:ietf:params:xml:ns:epp-1.0 namespace. Previous Comments: [2009-11-17 11:30:48] a dot testa at wifisolution dot it here sample code that can reproduce the problem class DOMDocument_NIC extends DOMDocument{ public function isValid_onfile(){ $tempFile = time() . '-' . rand() . '-xmlvalidation.tmp'; $this-save($tempFile); // Create temporary DOMDocument_NIC and re-load content from file. $tempDom = new DOMDocument(); $tempDom-load($tempFile); // Delete temporary file. if (is_file($tempFile)){ unlink($tempFile); } return $tempDom-schemaValidate('hosting_epp_nic_it/epp-1.0.xsd'); } public function isValid_onfly(){ return $this-schemaValidate('hosting_epp_nic_it/epp-1.0.xsd'); } } $doc = new DOMDocument_NIC('1.0', 'UTF-8'); $doc-xmlStandalone='no'; $xml_epp = $doc-createElementNS(urn:ietf:params:xml:ns:epp-1.0,'epp'); $doc-appendChild($xml_epp); $xml_epp-setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $xml_epp-setAttributeNS('http://www.w3.org/2001/XMLSchema-instance' ,'xsi:schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd'); $xml_command = $doc-createElement('command'); $xml_epp-appendChild($xml_command); $xml_login = $doc-createElement('logout'); $xml_command-appendChild($xml_login); $xml_cltrid = $doc-createElement('clTRID',123456); $xml_command-appendChild($xml_cltrid); //$response = new DOMDocument_NIC(); //$response-loadXML($xml); echo htmlentities($doc-saveXML()).br /; echo Valido on File: .$doc-isValid_onfile(); echo Valido on Fly: .$doc-isValid_onfly(); [2009-11-17 10:11:27] rricha...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. [2009-11-17 09:48:59] a dot testa at wifisolution dot it Description: php fails to validate a xml against a xsd. the xml is build with the DOM interface. the function schemaValidate returns true if i load the document from a file but not with the same document created on the fly. as workaround i can create the document, write it on a file, load againt and then validate. -- Edit this bug report at http://bugs.php.net/?id=50201edit=1
#48502 [Opn-Bgs]: Error in constructor for DOMElement
ID: 48502 Updated by: rricha...@php.net Reported By: trex6 at mail dot ru -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: GNU/Linux PHP Version: 5.2.9 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php as Rasmus indicated use saveXML to get closing tag because there is none in HTML. Previous Comments: [2009-06-09 05:58:14] chr...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. If I make a complete script out of your snippet like *** ?php $dom = new domdocument(); $dom-loadXML(foo/); $ParentElement = $dom-documentElement; $imgPic = new DOMElement(img); $ParentElement-appendChild($imgPic); $imgPic-setAttribute(src,./1.jpg); print $dom-saveXML(); *** I get ?xml version=1.0? fooimg src=./1.jpg//foo which looks perfectly fine to me. So please send a complete, reproducable script. And: You should use domdocument-createElement() and not new domelement (but doesn't seem to be the root of the problem) [2009-06-09 05:58:08] ras...@php.net If you use saveXML() it does. If you use saveHTML(), it doesn't because that is how it is supposed to be in HTML. If you want XHTML, use saveXML() [2009-06-09 05:35:39] trex6 at mail dot ru Description: I want add img element to my xml document. Reproduce code: --- $imgPic = new DOMElement(img); $ParentElement-appendChild($imgPic); $imgPic-setAttribute(src,./1.jpg); Expected result: img src=./1.jpg / Actual result: -- img src=./1.jpg Script doesn`t generate closled '/' for tag img. -- Edit this bug report at http://bugs.php.net/?id=48502edit=1
#49646 [Opn-Bgs]: DOM LoadHTMLfile error
ID: 49646 Updated by: rricha...@php.net Reported By: taylorms at mtaonline dot net -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Linux PHP Version: 5.3SVN-2009-09-23 (snap) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: [2009-09-23 23:12:21] taylorms at mtaonline dot net sjo...@php.net You are correct. I first removed the and there was no problem. I then replaced with amp; and still no problem. I guess I did not realize that you needed to escape in javascript, since earlier in the HTML is a javascript with plenty of s in it. Perhaps the onclick is not parsed by the loadHTMLfile as javascript since it is enclosed in . Thanks for your quick reply. Shane [2009-09-23 20:02:33] sjo...@php.net Thank you for your bug report. If I recall correctly, ampersands need to be escaped in HTML, including in links and the like. This means that this is a bug in your HTML and not in the DOM parser. Please try to put your file through W3Cs HTML validator at http://validator.w3.org/ . [2009-09-23 19:53:24] taylorms at mtaonline dot net Description: The line of HTML below causes DOM LoadHTMLfile to throw the following exception: DOMDocument::loadHTMLFile() [a href='function.DOMDocument-loadHTMLFile'function.DOMDocument-loadHTMLFile/a]: htmlParseEntityRef: expecting ';' in contactus.html, line: 111 Line 111 of contactus.html is a link with an onclick with multiline (; separated) embedded javascript. The source line is shown in the code section. Note that if I create a javascript function, and reference only the function name in the 'onclick=', the error is NOT produced (also shown). It appears the parser is getting confused with the embedded javascript in this statement. Reproduce code: --- --- From manual page: domdocument.loadhtmlfile --- HTML Source that causes error: a class=social_buttons href=http://www.facebook.com/share.php?u=aboutfaceak.com; onclick=u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false; target=_blankimg class=social_img src=../images/facebook_share.png //a The following code with a change to onclick does NOT cause an error: a class=social_buttons href=http://www.facebook.com/share.php?u=aboutfaceak.com; ONCLICK=RETURN FBSHARE(); target=_blankimg class=social_img src=../images/facebook_share.png //a Expected result: The onclick javascript code opens a new window with a facebook php app that uses the URL of the page where the link was clicked as the link to share on facebook. If javascript is disabled, the generic link listed in href is used instead of the actual current page URL. Actual result: -- The error shown in the description is thrown (and caught/logged) when the loadHTMLfile function is called with the source file containing the above source line. -- Edit this bug report at http://bugs.php.net/?id=49646edit=1
#49275 [Opn-Bgs]: Node no longer exists error when storing simplexml object to session
ID: 49275 Updated by: rricha...@php.net Reported By: michaelwalser at gmx dot net -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Debian Lenny PHP Version: 5.3.0 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Cannot serialize object wrapping 3rd party library structs. Must serialize the xml (to a string) and store that to session and reload the xml when restoring from session Previous Comments: [2009-08-17 08:01:58] michaelwalser at gmx dot net Description: Hi, this code says more than 1000 words ;) Reproduce code: --- ?php session_start(); if(!isset($_SESSION['xml'])) { $xml = simplexml_load_string('?xml version=1.0 encoding=UTF-8? blah/blah'); $_SESSION['xml'] = $xml; echo Session variable set... Please hit F5; } else { $wtf = $_SESSION['xml']; if($wtf) echo 'lol'; // This triggers the error } ? Actual result: -- Warning: session_start() [function.session-start]: Node no longer exists in /var/www/phperr.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/phperr.php:2) in /var/www/phperr.php on line 2 Warning: main() [function.main]: Node no longer exists in /var/www/phperr.php on line 14 Warning: Unknown: Node no longer exists in Unknown on line 0 -- Edit this bug report at http://bugs.php.net/?id=49275edit=1
#48095 [Ver-Bgs]: Load RDF Format Error
ID: 48095 Updated by: rricha...@php.net Reported By: pigo_chu at hotmail dot com -Status: Verified +Status: Bogus Bug Type: *XML functions Operating System: win32 only - Windows XP SP3 PHP Version: 5.2.9 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. This is caused by some problem in the libiconv library. Your Linux system is mostly using the glibc implementation which is why it works there. Not a PHP issue but a libiconv problem. Previous Comments: [2009-04-28 22:22:30] f...@php.net The URL mentioned passes http://www.w3.org/RDF/Validator/ as of now. 5.2.9 on Linux reads it correctly, 5.2.9-2 on XP / SP3 yields this result: PHP Warning: simplexml_load_file(): input conversion failed due to input error, bytes 0xA1 0xFE 0xA6 0xCC in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): input conversion failed due to input error, bytes 0xA1 0xFE 0xA6 0xCC in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): encoder errorhttp://www.nownews.com/rss/realtime.rdf:79: parser error : Premature end of data in tag title line 79 in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): title#31933;#23376;#25512;#34214; in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file():^ in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): http://www.nownews.com/rss/realtime.rdf:79: parser error : Premature end of data in tag item line 77 in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): title#31933;#23376;#25512;#34214; in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file():^ in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): http://www.nownews.com/rss/realtime.rdf:79: parser error : Premature end of data in tag RDF line 2 in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file(): title#31933;#23376;#25512;#34214; in D:\code\48095.php on line 2 PHP Warning: simplexml_load_file():^ in D:\code\48095.php on line 2 [2009-04-28 03:25:07] pigo_chu at hotmail dot com Description: The url http://www.nownews.com/rss/realtime.rdf is rdf document Use any xml function(simplexml or domdocument) to load the url On Linux PHP 5.2.9 is ok On Windows XP SP3 has error Reproduce code: --- $doc = simplexml_load_file('http://www.nownews.com/rss/realtime.rdf'); var_dump($doc); Expected result: output is 'false' -- Edit this bug report at http://bugs.php.net/?id=48095edit=1
#49251 [Ver-Bgs]: wrong object created
ID: 49251 Updated by: rricha...@php.net Reported By: ies_clan at hotmail dot com -Status: Verified +Status: Bogus Bug Type: SimpleXML related Operating System: * PHP Version: 5.*, 6 (2009-08-17) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php simpleXML returns simpleXML objects when accessing properties of the document, and calling new on the returned object, creates a new object of that type returned. You need to cast to string before calling new, i.e.: $mclass = (string)$Xml-classname; $XmlClass = new $mclass('root /'); Previous Comments: [2009-08-17 18:22:32] j...@php.net And it only happens with 'new'. [2009-08-17 18:19:09] j...@php.net Quite weird indeed. And verified in all branches. [2009-08-14 13:49:22] ies_clan at hotmail dot com Description: if u try to create a new object from an simple xml-objekt-property you got an simple xml object :( Reproduce code: --- class test {} $Xml = new SimpleXMLElement('rootclassnamestdclass/classname/root'); $XmlClass = new $Xml-classname('root /'); print_r($XmlClass); $MyClass = new stdclass(); $MyClass-classname = 'test'; $stdclass = new $MyClass-classname(); print_r($stdclass); Expected result: stdclass Object ( ) test Object ( ) Actual result: -- SimpleXMLElement Object ( ) test Object ( ) -- Edit this bug report at http://bugs.php.net/?id=49251edit=1
#49647 [Opn-Csd]: DOMUserData does not exist
ID: 49647 Updated by: rricha...@php.net Reported By: ashn...@php.net -Status: Open +Status: Closed Bug Type: Reflection related Operating System: Linux PHP Version: 5.3.0 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/. Thank you for the report, and for helping us make PHP better. type is mixed not DOMUserData Previous Comments: [2009-09-24 13:18:22] s...@php.net Automatic comment from SVN on behalf of rrichards Revision: http://svn.php.net/viewvc/?view=revisionrevision=288654 Log: Fixed bug #49647 (DOMUserData does not exist) [2009-09-24 11:31:08] ashn...@php.net Yes, ext/dom is enabled -: $ php -i | grep -i dom dom DOM/XML = enabled DOM/XML API Version = 20031129 I'll modify the test script to verify it also --: ?php echo 'Verify DOM is loaded:' . PHP_EOL; $r1 = new ReflectionClass('DOMElement'); var_dump($r1-getName()); echo PHP_EOL; echo 'Does DOMUserData exist?' . PHP_EOL; $r2 = new ReflectionClass('DOMUserData'); var_dump($r2-getName()); ? With expected output : Verify DOM is loaded: string(10) DOMElement Does DOMUserData exist? string(11) DOMUserData And actual output ---: Verify DOM is loaded: string(10) DOMElement Does DOMUserData exist? PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class DOMUserData does not exist' in /opt/phpversions/php-bin/php-5.3.0/test.php:8 Stack trace: #0 /opt/phpversions/php-bin/php-5.3.0/test.php(8): ReflectionClass-__construct('DOMUserData') #1 {main} thrown in /opt/phpversions/php-bin/php-5.3.0/test.php on line 8 ReflectionException: Class DOMUserData does not exist in /opt/phpversions/php-bin/php-5.3.0/test.php on line 8 Call Stack: 0.0002 624160 1. {main}() /opt/phpversions/php-bin/php-5.3.0/test.php:0 0.0004 625432 2. ReflectionClass-__construct() /opt/phpversions/php-bin/php-5.3.0/test.php:8 This bug report was prompted by PEAR bug #14640, where phpDocumenter encounters the same ReflectionException when attempting to document the DOMElement parent class of a user's code class that extends DOMElement. Declaring an empty dummy DOMUserData class in the user's code solves the issue. [2009-09-24 10:03:36] j...@php.net Is ext/dom enabled in your build? And loaded? :) [2009-09-23 22:00:48] ashn...@php.net Description: Reflection actitivy against a child of DOMElement can result in: ReflectionException: Class DOMUserData does not exist presumably due to dom_node_get_user_data in ext/dom/node.c. The actual class does not appear to exist, although the method shows it as a datatype for a parameter. Reproduce code: --- ?php $r2 = new ReflectionClass('DOMUserData'); echo r2-getName(); ? Expected result: DOMUserData Actual result: -- ReflectionException: Class DOMUserData does not exist -- Edit this bug report at http://bugs.php.net/?id=49647edit=1
#48916 [Opn-Bgs]: Add feature to delete XML node in SimpleXML
ID: 48916 Updated by: rricha...@php.net Reported By: piotr dot baranowski at zeno dot pl -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: All of them PHP Version: 5.2.10 New Comment: no need for additional method. unset() performs deletions Previous Comments: [2009-07-14 14:53:03] piotr dot baranowski at zeno dot pl Description: Just as in the title. There's no way now to delete XML node in SimpleXML. It would be nice to have SimpleXML method that would delete given node. Reproduce code: --- --- From manual page: book.simplexml --- -- Edit this bug report at http://bugs.php.net/?id=48916edit=1
#48202 [Asn-Bgs]: Out of memory error when passing non-existing filename to xmlwriter_open_uri()
ID: 48202 Updated by: rricha...@php.net Reported By: koenk82 at gmail dot com -Status: Assigned +Status: Bogus Bug Type: XML Writer Operating System: * PHP Version: 5.*, 6CVS (2009-05-09) Assigned To: rrichards New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Error message was fixed in libxml2 source - will be in the 2.7.4 release Previous Comments: [2009-05-30 22:14:16] paj...@php.net Rob, can you take a look please? Maybe change the error in xmlNewTextWriterFilename from: out = xmlOutputBufferCreateFilename(uri, NULL, compression); if (out == NULL) { xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, xmlNewTextWriterFilename : out of memory!\n); return NULL; } to out = xmlOutputBufferCreateFilename(uri, NULL, compression); if (out == NULL) { xmlWriterErrMsg(NULL, XML_EIO, xmlNewTextWriterFilename : cannot create file %s\n, uri); return NULL; } [2009-05-30 20:59:38] paj...@php.net I found the problem, it is a bug in libxml's xmlwriter. It does not check correctly the return value from the createfilename callback. [2009-05-26 14:12:42] fel...@php.net It's reproducible yet. $ sapi/cli/php -r 'xmlwriter_open_uri(file:///a);' Warning: xmlwriter_open_uri(/a): failed to open stream: Permission denied in Command line code on line 1 Warning: xmlwriter_open_uri(): xmlNewTextWriterFilename : out of memory! in Command line code on line 1 [2009-05-25 16:53:52] paj...@php.net This bug has been fixed in CVS. 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/. Thank you for the report, and for helping us make PHP better. fixed in 5.2, 5.3 and HEAD [2009-05-09 13:04:56] paj...@php.net reproduced during the testfest 2009/utrecht, assigning to me. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/48202 -- Edit this bug report at http://bugs.php.net/?id=48202edit=1
#48339 [Asn-Fbk]: DOMElement::setIdAttribute() throws 'Not Found Error' exception
ID: 48339 Updated by: rricha...@php.net Reported By: greatwhitepine at bigfoot dot com -Status: Assigned +Status: Feedback Bug Type: DOM XML related Operating System: opensuse 11.1 PHP Version: 5.2.9 Assigned To: rrichards New Comment: Did you upgrade libxml2 while upgrading PHP? The has been no change in the setIdAttribute() method. Previous Comments: [2009-05-19 23:17:23] greatwhitepine at bigfoot dot com Description: DOMElement::setIdAttribute() is broken in 5.2.9. It works properly in 5.2.6. Reproduce code: --- ?php // php_dom_setidattribute_bug.php $obj_domDocument = new DOMDocument( ); $obj_domElement = $obj_domDocument-createElement( 'test', 'This is the root element!' ); $obj_domElement = $obj_domDocument-appendChild( $obj_domElement ); $obj_domElement-setAttribute( 'xml:id', 1 ); $obj_domElement-setIdAttribute( 'xml:id', TRUE ); print $obj_domDocument-saveXML( ); ? Expected result: This should not throw any exception. Actual result: -- PHP Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in /home/gwp/bin/php_dom_setidattribute_bug.php:13 Stack trace: #0 /home/gwp/bin/php_dom_setidattribute_bug.php(13): DOMElement-setIdAttribute('xml:id', true) #1 {main} thrown in /home/gwp/bin/php_dom_setidattribute_bug.php on line 13 Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in /home/gwp/bin/php_dom_setidattribute_bug.php:13 -- Edit this bug report at http://bugs.php.net/?id=48339edit=1
#48352 [Opn]: Method registerNodeClass does not work with DOMNodeList
ID: 48352 Updated by: rricha...@php.net Reported By: php at xxlwebdesign dot de Status: Open -Bug Type: DOM XML related +Bug Type: Feature/Change Request Operating System: Gentoo PHP Version: 5.3CVS-2009-05-21 (snap) -Assigned To: +Assigned To: rrichards New Comment: This method was designed specifically for DOMNode based classes only. changing to feature request and I will consider and evaluate expanding its functionality. Previous Comments: [2009-05-21 09:38:59] php at xxlwebdesign dot de Description: The method DOMDocument-registerNodeClass does not work with DOMNodeList Reproduce code: --- ?php class MyNodeList extends DOMNodeList { } $dom = new DOMDocument(); $dom-registerNodeClass('DOMNodeList', 'MyNodeList'); ? Actual result: -- Fatal error: DOMDocument::registerNodeClass() [a href='domdocument.registernodeclass'domdocument.registernodeclass/a]: Class DOMNodeList is not derived from DOMNode. in ... -- Edit this bug report at http://bugs.php.net/?id=48352edit=1
#48096 [Fbk]: Error reading XML string
ID: 48096 Updated by: rricha...@php.net Reported By: bbarnett at gt dot co dot cr Status: Feedback Bug Type: DOM XML related Operating System: Windows 2003 Server R2 PHP Version: 5.2.9 New Comment: You are still missing all the values being populated as well as another function. Previous Comments: [2009-04-29 16:22:18] bbarnett at gt dot co dot cr This is the function that I use to complete the length of the string function llenacampo($valor,$tamano,$llenado,$justificado){ // Esta funcion devuelve el valor basado en los parametros para ser agregado en la trama $devuelve=''; if ($justificado=='derecha'){ //Llena el campo de derecha a izquierda $cuanto=$tamano-strlen(trim($valor)); for ($i=0;$i$cuanto;$i++){ $devuelve.=$llenado; } $devuelve.=$valor; } elseif ($justificado=='izquierda'){ //Llena el campo de derecha a izquierda $devuelve.=$valor; $cuanto=$tamano-strlen(trim($valor)); for ($i=0;$i$cuanto;$i++){ $devuelve.=$llenado; } } return $devuelve; } [2009-04-28 11:57:32] rricha...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Included script does not run because you are using functions and variables that are not included here. As I said before this is an encoding issue and I would bet it due to the values of them. [2009-04-28 06:44:37] bbarnett at gt dot co dot cr This is an example of the XML string: ?xml version=1.0? X_A_PagoGen Banco2/Banco Localizacion2603460081/Localizacion NotaCredito9787/NotaCredito Correlativo82108608/Correlativo Self9/Self Monto003930/Monto Agencia1400/Agencia FechaPago20090427/FechaPago FechaCaja20090428/FechaCaja /X_A_PagoGen [2009-04-28 06:36:40] bbarnett at gt dot co dot cr Description: I'm receiving and errors when I try to read and XML string, previously generated by my code. Reproduce code: --- $doc = new DOMDocument('1.0'); $doc-formatOutput = true; $root = $doc-createElement('X_A_PagoGen'); $root = $doc-appendChild($root); $title = $doc-createElement('Banco'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($codigobanco)); $text = $title-appendChild($text); $title = $doc-createElement('Localizacion'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($localizacion)); $text = $title-appendChild($text); $title = $doc-createElement('NotaCredito'); $title = $root-appendChild($title); $text = $doc-createTextNode(llenacampo(trim($remesa),12,'0','derecha')); $text = $title-appendChild($text); $title = $doc-createElement('Correlativo'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($factura)); $text = $title-appendChild($text); $title = $doc-createElement('Self'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($self)); $text = $title-appendChild($text); $title = $doc-createElement('Monto'); $title = $root-appendChild($title); $text = $doc-createTextNode(llenacampo(trim($monto),10,'0','derecha')); $text = $title-appendChild($text); $title = $doc-createElement('Agencia'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($recaudadorCNFL)); $text = $title-appendChild($text); $title = $doc-createElement('FechaPago'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim(fecha1())); $text = $title-appendChild($text); $title = $doc-createElement('FechaCaja'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($deposito)); $text = $title-appendChild($text); $tramaxml=$doc-saveXML(); $xml2= simplexml_load_string(trim($tramaxml)); Expected result: XML Object Actual result: -- Error: Fatal Error 73: Couldn't find end of Start Tag Fech line 10 Line: 10 Column: 8 Fatal Error 77: Premature end of data in tag X_A_PagoGen line 2 Line: 10 Column: 8
#48109 [Opn-Bgs]: DOM interpolates specific entities (apos and quot)
ID: 48109 Updated by: rricha...@php.net Reported By: robin dot mehner at freak-company dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: MacOSX / Debian Linux PHP Version: 5.2.9 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Handling of those pre-defined entities is dependent upon the XMl parser and that is how libxml handles them. Previous Comments: [2009-04-29 13:58:03] robin dot mehner at freak-company dot com phpt for this bug can be found at: http://friendpaste.com/2jrhQQ0OzJosv243FDwyGe Hope this helps. [2009-04-29 13:55:41] robin dot mehner at freak-company dot com Description: DomDocument interpolates the apos; and quot; entities to their values (' and ). Other entities like gt; etc. are displayed as is. Tested with php version 5.2.6 (self-compiled under debian), 5.2.9 and 5.3RC1 on MacOSX. Further version infos can be posted if needed. Reproduce code: --- ?php // create document (keep it simple) $domImp = new DomImplementation(); $dom = $domImp-createDocument(null, 'root'); // create element $foo = $dom-createElement('foo', 'apos; quot;'); // bug here $dom-documentElement-appendChild($foo); echo $dom-saveXML(); Expected result: ?xml version=1.0? rootfooapos; quot;/foo/root Actual result: -- ?xml version=1.0? rootfoo' /foo/root -- Edit this bug report at http://bugs.php.net/?id=48109edit=1
#48096 [Opn-Fbk]: Error reading XML string
ID: 48096 Updated by: rricha...@php.net Reported By: bbarnett at gt dot co dot cr -Status: Open +Status: Feedback Bug Type: DOM XML related Operating System: Windows 2003 Server R2 PHP Version: 5.2.9 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Included script does not run because you are using functions and variables that are not included here. As I said before this is an encoding issue and I would bet it due to the values of them. Previous Comments: [2009-04-28 06:44:37] bbarnett at gt dot co dot cr This is an example of the XML string: ?xml version=1.0? X_A_PagoGen Banco2/Banco Localizacion2603460081/Localizacion NotaCredito9787/NotaCredito Correlativo82108608/Correlativo Self9/Self Monto003930/Monto Agencia1400/Agencia FechaPago20090427/FechaPago FechaCaja20090428/FechaCaja /X_A_PagoGen [2009-04-28 06:36:40] bbarnett at gt dot co dot cr Description: I'm receiving and errors when I try to read and XML string, previously generated by my code. Reproduce code: --- $doc = new DOMDocument('1.0'); $doc-formatOutput = true; $root = $doc-createElement('X_A_PagoGen'); $root = $doc-appendChild($root); $title = $doc-createElement('Banco'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($codigobanco)); $text = $title-appendChild($text); $title = $doc-createElement('Localizacion'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($localizacion)); $text = $title-appendChild($text); $title = $doc-createElement('NotaCredito'); $title = $root-appendChild($title); $text = $doc-createTextNode(llenacampo(trim($remesa),12,'0','derecha')); $text = $title-appendChild($text); $title = $doc-createElement('Correlativo'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($factura)); $text = $title-appendChild($text); $title = $doc-createElement('Self'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($self)); $text = $title-appendChild($text); $title = $doc-createElement('Monto'); $title = $root-appendChild($title); $text = $doc-createTextNode(llenacampo(trim($monto),10,'0','derecha')); $text = $title-appendChild($text); $title = $doc-createElement('Agencia'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($recaudadorCNFL)); $text = $title-appendChild($text); $title = $doc-createElement('FechaPago'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim(fecha1())); $text = $title-appendChild($text); $title = $doc-createElement('FechaCaja'); $title = $root-appendChild($title); $text = $doc-createTextNode(trim($deposito)); $text = $title-appendChild($text); $tramaxml=$doc-saveXML(); $xml2= simplexml_load_string(trim($tramaxml)); Expected result: XML Object Actual result: -- Error: Fatal Error 73: Couldn't find end of Start Tag Fech line 10 Line: 10 Column: 8 Fatal Error 77: Premature end of data in tag X_A_PagoGen line 2 Line: 10 Column: 8 -- Edit this bug report at http://bugs.php.net/?id=48096edit=1
#47953 [Opn-Bgs]: Error reading XML string
ID: 47953 Updated by: rricha...@php.net Reported By: bbarnett at gt dot co dot cr -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: WXP PHP Version: 5.2.9 New Comment: There's bad data somewhere in your XML. No idea what encoding the data is, but converting it to ISO-8859-1 without an XML declaration using that encoding is a sure path to disaster. Previous Comments: [2009-04-12 00:07:46] bbarnett at gt dot co dot cr This is a part of the code that I'm using: ? $consulta=select trama from gestiones where consecutivo=.trim($_REQUEST['consecutivo']); $buffconsulta = mssql_query($consulta,$conn); $reg = mssql_fetch_row($buffconsulta); // Procesa el XML enviado $xml2= simplexml_load_string(utf8_decode(trim($reg[0]))); if (!$xml2){ print wordwrap($reg[0], 30, br,1); } ? [2009-04-12 00:03:21] bbarnett at gt dot co dot cr This is an example of the XML string that I'm trying to read X_A_PagoGen Banco2/Banco Localizacion8203261610/Localizacion NotaCredito9770/NotaCredito Correlativo80782584/Correlativo Self9/Self Monto011930/Monto Agencia1400/Agencia FechaPago20090216/FechaPago FechaCaja20090217/FechaCaja /X_A_PagoGen [2009-04-11 23:49:39] bbarnett at gt dot co dot cr Description: I'm receiving and error when I try to read and XML string. The error is: Premature end of data in tag FechaPago line 9 Line: 9 Reproduce code: --- $xml2= simplexml_load_string(utf8_decode(trim($reg[0]))); Expected result: An XML object Actual result: -- An Error. -- Edit this bug report at http://bugs.php.net/?id=47953edit=1
#47953 [Bgs]: Error reading XML string
ID: 47953 Updated by: rricha...@php.net Reported By: bbarnett at gt dot co dot cr Status: Bogus Bug Type: SimpleXML related Operating System: WXP PHP Version: 5.2.9 New Comment: Not a bug. You have bad data - most likely an invisible char. Previous Comments: [2009-04-15 15:58:53] bbarnett at gt dot co dot cr I'm adding the XML head to the string like this ?xml version=1.0 encoding=UTF-8? X_A_PagoGen Banco2/Banco Localizacion7901160655/Localizacion NotaCredito9726/NotaCredito Correlativo79613565/Correlativo Self5/Self Monto010605/Monto Agencia1400/Agencia FechaPago20090102/FechaPago FechaCaja20090105/FechaCaja /X_A_PagoGen But I'm receiving the same result. In the next case the function read the XML without problem X_C_Localizacion Localizacion7901160655/Localizacion /X_C_Localizacion [2009-04-15 15:40:06] bbarnett at gt dot co dot cr I try without the utf8_decode, but I'm receiving the same result. $xml2= simplexml_load_string(trim($reg[0])); Can you help me? [2009-04-15 11:55:16] rricha...@php.net There's bad data somewhere in your XML. No idea what encoding the data is, but converting it to ISO-8859-1 without an XML declaration using that encoding is a sure path to disaster. [2009-04-12 00:07:46] bbarnett at gt dot co dot cr This is a part of the code that I'm using: ? $consulta=select trama from gestiones where consecutivo=.trim($_REQUEST['consecutivo']); $buffconsulta = mssql_query($consulta,$conn); $reg = mssql_fetch_row($buffconsulta); // Procesa el XML enviado $xml2= simplexml_load_string(utf8_decode(trim($reg[0]))); if (!$xml2){ print wordwrap($reg[0], 30, br,1); } ? [2009-04-12 00:03:21] bbarnett at gt dot co dot cr This is an example of the XML string that I'm trying to read X_A_PagoGen Banco2/Banco Localizacion8203261610/Localizacion NotaCredito9770/NotaCredito Correlativo80782584/Correlativo Self9/Self Monto011930/Monto Agencia1400/Agencia FechaPago20090216/FechaPago FechaCaja20090217/FechaCaja /X_A_PagoGen The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/47953 -- Edit this bug report at http://bugs.php.net/?id=47953edit=1
#47849 [Opn-Csd]: Non-deep import loses the namespace
ID: 47849 Updated by: rricha...@php.net Reported By: robin2008 at altruists dot org -Status: Open +Status: Closed Bug Type: DOM XML related Operating System: Ubuntu PHP Version: 5.2.9 New Comment: This bug has been fixed in CVS. 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2009-03-31 11:48:32] robin2008 at altruists dot org Description: I was expecting importNode to respect namespace Reproduce code: --- ?php // PHP 5.2.* namespace bug - importNode doesn't preserve the namespace if deep=0. $aDOM= new DOMDocument(); $aDOM-appendChild($aDOM-createElementNS(' http://friend2friend.net/ ','f2f:a')); echo 'DOM to add into is '.$aDOM-saveXML().chr(13); $fromdom= DOMDocument::loadXML('data xmlns= http://altruists.org /'); echo 'Dom to import from is'.$fromdom-saveXML().chr(13); $data= $fromdom-firstChild; $aDOM-documentElement-appendChild($aDOM-importNode($data)); echo 'Result is '.$aDOM-saveXML(); ? Expected result: The manual says This function returns a copy of the node to import and associates it with the current document. so I was expecting it to preserve the namespace Actual result: -- The namespace gets lost. -- Edit this bug report at http://bugs.php.net/?id=47849edit=1
#47666 [Opn-Bgs]: SaveXML not well formed
ID: 47666 Updated by: rricha...@php.net Reported By: info at pcxtra dot nl -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Fedora 9 PHP Version: 5.2.9 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. . Previous Comments: [2009-03-15 21:23:12] info at pcxtra dot nl Description: SaveXML method generates html element with TWO xmlns attributes (which is not well formed XML). Reproduce code: --- $html = HTML !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head /head body /body /html HTML; $doc = new DOMDocument(); $doc-loadHTML( $html ); $result = $doc-saveXML(); $doc2 = new DOMDocument(); $doc2-loadXML( $result ); $result2 = $doc-saveXML(); echo $result2; Expected result: The expected result is: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head /head body /body /html Actual result: -- Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Attribute xmlns redefined in Entity, line: 3 in /home/siuser/www/dev/engine/100/test.php on line 21 $result shows two xmlns attributes for the html element: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xmlns=http://www.w3.org/1999/xhtml; head /head body /body /html -- Edit this bug report at http://bugs.php.net/?id=47666edit=1
#47430 [Asn-Csd]: Errors after writing to nodeValue parameter of an absent previousSibling
ID: 47430 Updated by: rricha...@php.net Reported By: bisyarin at ukr dot net -Status: Assigned +Status: Closed Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2CVS-2009-02-17 (snap) Assigned To: rrichards New Comment: This bug has been fixed in CVS. 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2009-02-20 23:48:09] fel...@php.net The problem is the 'retval = EG(uninitialized_zval_ptr);' in dom_read_property(), I guess that maybe would be more suitable throw an E_RECOVERABLE_ERROR there. Assigned to maintainer. [2009-02-18 23:47:36] fel...@php.net I can reproduce it using 5.3CVS. [2009-02-18 00:39:01] bisyarin at ukr dot net I've tried PHP 5.2.9RC3-dev on windows and FreeBSD and still the same. Output from my win-machine: version: PHP 5.2.9RC3-dev (cli) (built: Feb 17 2009 23:39:59) Error message: PHP Fatal error: Cannot use object of type stdClass as array in D:\artem\phpDOMBagTest.php on line 19 Output from my FreeBSD machine: version: PHP 5.2.9RC3-dev (cli) (built: Feb 18 2009 02:14:56) Error message: Fatal error: Cannot use object of type stdClass as array in /usr/home/artem/comps/scripts/phpDOMBagTest.php on line 19 [2009-02-17 23:54:19] j...@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ [2009-02-17 23:01:30] bisyarin at ukr dot net Description: In one of my project's libraries I've forgot to check DOMNode's previousSibling property for existence by accident. I think that DOM extension should handle such situations gracefully. But after that, when I try to create an array by assigning a value to unexistent key with square bracket syntax, I get an error message: PHP Fatal error: Cannot use object of type stdClass as array in /xxx/yyy.php on line ZZZ Reproduce code: --- $xml = '?xml version=1.0?htmlpiHello/i/ppiWorld!/i/p/html'; $dom = new DOMDocument(); $dom-loadXML($xml); $elements = $dom-getElementsByTagName('i'); foreach ($elements as $i) { $i-previousSibling-nodeValue = ''; } $arr[0] = 'Value'; print_r($arr); Expected result: Array ( [0] = Value ) Actual result: -- PHP Fatal error: Cannot use object of type stdClass as array in /usr/home/artem/comps/scripts/test.php on line 20 -- Edit this bug report at http://bugs.php.net/?id=47430edit=1
#47446 [Csd-Bgs]: Error docdocument::schemaValidate a valid schema
ID: 47446 Updated by: rricha...@php.net Reported By: apaella at gmail dot com -Status: Closed +Status: Bogus Bug Type: DOM XML related Operating System: WIN XP PRO PHP Version: 5.3.0beta1 New Comment: . Previous Comments: [2009-02-19 10:59:54] apaella at gmail dot com updated libxml to version 2.7.3 and fixed. sorry for my mistake [2009-02-19 08:18:19] apaella at gmail dot com Description: Trying to validate a valid XML (AltovaXML commandline Liquid XML Studio says that) I got a local complex type:The content type must specify a particle. error... Reproduce code: --- $xmlString= '?xml version=1.0? OTA_AirAvailRQ xmlns=http://www.opentravel.org/OTA/2003/05; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; TimeStamp=2009-02-18T16:24:59 MaxResponses=5 Target=Production Version=2008.02 SequenceNmbr=1 EchoToken=960 xsi:schemaLocation=http://www.opentravel.org/OTA/2003/05 http://www.opentravel.org/2008B/OTA_AirAvailRQ.xsd; POS Source PseudoCityCode=IPCC / /POS OriginDestinationInformation DepartureDateTime2009-03-10T20:00:00/DepartureDateTime OriginLocation LocationCode=TNR / DestinationLocation LocationCode=OLB / /OriginDestinationInformation TravelPreferences MaxStopsQuantity=2 / /OTA_AirAvailRQ'; $xdoc = new DomDocument(); $xdoc-loadXML($xmlString); $xdoc-schemaValidate(http://www.opentravel.org/2008B/ OTA_AirAvailRQ.xsd); Expected result: A valid schema result Actual result: -- Warning : local complex type:The content type must specify a particle. -- Edit this bug report at http://bugs.php.net/?id=47446edit=1
#47368 [Opn-Bgs]: XMLWriter::writeAttribute() doesn't display accented characters
ID: 47368 Updated by: rricha...@php.net Reported By: christian dot ubu at gmail dot com -Status: Open +Status: Bogus Bug Type: XML Writer Operating System: CentOS release 5.2 (Final) PHP Version: 5.2CVS-2009-02-12 (CVS) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php certain characters get written as character references within attribute values. That happens to one of them. Also make sure your encodings are correct because when run within UTF-8 env, the output is: test testé=test#xE9;/ which is correct Previous Comments: [2009-02-12 12:32:22] christian dot ubu at gmail dot com Description: XMLWriter::writeAttribute() doesn't display the value of the attribute with accented characters. Reproduce code: --- ?php $w = new XMLWriter(); $w-openURI('php://output'); $w-startElement('test'); $w-writeAttribute('testé', 'testé'); $w-endElement(); $w-outputMemory(); ? Expected result: test testé=testé/ Actual result: -- test testé=test#x9005;#10;#x59;/ -- Edit this bug report at http://bugs.php.net/?id=47368edit=1
#47137 [Opn-Bgs]: LIBXML_NOXMLDECL is not working anymore
ID: 47137 Updated by: rricha...@php.net Reported By: romain dot lalaut at laposte dot net -Status: Open +Status: Bogus Bug Type: XML related Operating System: Linux PHP Version: 5.3.0alpha3 New Comment: That is a save option which hasn't yet been implemented so has never worked Previous Comments: [2009-01-17 13:58:07] romain dot lalaut at laposte dot net Description: It seems that saving a DOMDocument which is loaded with LIBXML_NOXMLDECL doesn't avoid to get the xml declaration. It is a big problem to produce a xhtml document for internet because IE6 is not dead yet. Tested with libxml2 2.6.32 and 2.7.2 Reproduce code: --- ?php $xml = 'myxml/'; $doc = new DOMDocument(); $doc-loadXml($xml, LIBXML_NOXMLDECL); echo $doc-saveXML(); Expected result: myxml/ Actual result: -- ?xml version=1.0? myxml/ -- Edit this bug report at http://bugs.php.net/?id=47137edit=1
#47206 [Asn-Bgs]: Unintended API change in XSLTProcessor
ID: 47206 Updated by: rricha...@php.net Reported By: nfor...@php.net -Status: Assigned +Status: Bogus Bug Type: XSLT related Operating System: Linux PHP Version: 5.3CVS-2009-01-24 (snap) Assigned To: rrichards New Comment: The type hint added in 5.2.6 broke BC and wasn't detected until post 5.2.8 where it was fixed. It shouldn't have been added in the first place Previous Comments: [2009-02-03 12:06:18] chr...@php.net dmitry changed that 8 weeks ago with the message: *** MFH: fix arginfo - these also accept SimpleXMLElement *** http://cvs.php.net/viewvc.cgi/php-src/ext/xsl/xsltprocessor.c? r1=1.39.2.2.2.9.2.13r2=1.39.2.2.2.9.2.14 So, the removing of the typehint has a reason and I don't see a way to make it BC *and* accept SimpleXMLElement [2009-01-30 17:04:17] david dot zuelke at bitextender dot com (mind you, Rob, that this applies to transformToDoc(), too) [2009-01-30 17:01:14] johan...@php.net Rob, any problem with a atch like Index: ext/xsl/xsltprocessor.c === RCS file: /repository/php-src/ext/xsl/xsltprocessor.c,v retrieving revision 1.39.2.2.2.9.2.15 diff -u -p -r1.39.2.2.2.9.2.15 xsltprocessor.c --- ext/xsl/xsltprocessor.c 31 Dec 2008 11:15:47 - 1.39.2.2.2.9.2.15 +++ ext/xsl/xsltprocessor.c 30 Jan 2009 16:59:15 - @@ -29,7 +29,7 @@ /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_import_stylesheet, 0, 0, 1) - ZEND_ARG_INFO(0, doc) + ZEND_ARG_OBJ_INFO(0, doc, DOMDocument, 0) ZEND_END_ARG_INFO(); ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_transform_to_doc, 0, 0, 1) I didn't properly test it but it should work ... [2009-01-30 15:01:22] david dot zuelke at bitextender dot com Same problem here. Subclasses of XSLTProcessor can work without E_STRICT warning either in 5.2 or in 5.3, but not in both :( [2009-01-24 05:02:08] nfor...@php.net Description: In 5.3, attempting to extend XSLTProcessor in the same way as in 5.2 (with type hinting on the method parameters) yields an E_STRICT message: Declaration of ExtendedXSLTProcessor::importStylesheet() should be compatible with that of XSLTProcessor::importStylesheet(). Removing the type hint fixes the problem in 5.3. I am assuming this behavior is unintentional, and that the type hint should still be associated with the methods. This applies to both ::importStylesheet() and ::transformToDoc(), and potentially other methods as well. Reproduce code: --- ?php class ExtendedXSLTProcessor extends XSLTProcessor { public function importStylesheet(DOMDocument $stylesheet) { parent::importStylesheet($stylesheet); /* ... */ } } ? Actual result: -- Strict Standards: Declaration of ExtendedXSLTProcessor::importStylesheet() should be compatible with that of XSLTProcessor::importStylesheet() in /.../test.php on line 8 -- Edit this bug report at http://bugs.php.net/?id=47206edit=1
#47220 [Opn-Csd]: segfault in dom_document_parser in recovery mode
ID: 47220 Updated by: rricha...@php.net Reported By: felix-php at 7val dot com -Status: Open +Status: Closed Bug Type: DOM XML related Operating System: Debian Linux PHP Version: 5.2.8 New Comment: This bug has been fixed in CVS. 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/. Thank you for the report, and for helping us make PHP better. Previous Comments: [2009-01-26 16:54:42] felix-php at 7val dot com Description: A call to DOMDocument::load() or ::loadXML() in recovery mode leads to segmentation fault in dom_document_parser) when the XML declaration contains an unknown (and unrecoverable) encoding. The segfault occurs in document.c +1690 when trying to access properties of the result document (ret), which is NULL in this case: if (ret-URL == NULL ctxt-directory != NULL) { Reproduce code: --- ?php $xml = '?xml version=1.0 encoding=bad?'; $dom = new DOMDocument; $dom-recover = true; $dom-loadXML($xml); echo $dom-saveXML(); Expected result: ?xml version=1.0? Actual result: -- Segmentation Fault -- Edit this bug report at http://bugs.php.net/?id=47220edit=1
#47209 [Opn-Bgs]: DOMDocument's inferior parsing of malformed HTML
ID: 47209 Updated by: rricha...@php.net Reported By: queen dot zeal at gmail dot com -Status: Open +Status: Bogus Bug Type:DOM XML related PHP Version: 5.2.8 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php DOM is meant to handle XML conforming data (not broken HTML). It's not a libxml bug either. The HTML load functionality take best guess at trying to fix developer tag soup. Previous Comments: [2009-01-24 15:30:37] queen dot zeal at gmail dot com Description: I'm trying to get a list of all the input elements of a form tag and am having some difficulty doing so due to a PHP bug. First, here's my XHTML: div form action= input type=text name=a / /div div input type=text name=b / /div div input type=submit / /form /div It isn't semantically correct XHTML but that doesn't stop web developers from coding like that. Anyway, in both Firefox and IE, if you visit a webpage containing the above, and hit the Submit button, the resultant URL will have both a and b defined via GET. I'd like to be able to get a list of the same input parameters that the browser does for a given form element. I had been using // form[1]//input as an XPath query, but that doesn't work, here, because not all of the inputs are children of the form element. Indeed, if I use DOMDocument::saveHTML(), I get something more like this: div form action= input type=text name=a / /form /div div input type=text name=b / /div div input type=submit / /div Before you go off and pass the buck to the libxml developers, without even reviewing this, consider, first, that it might not be a bug in libxml, but rather, with PHP's bindings to libxml. Further, if you're going to be pass the buck, do so, yourself. I don't know C or C++ or whatever language libxml was originally intended to be used with. Since I don't know C / C++, if I were to file a bug report with the libxml developers, it'd have to be in PHP, which they may or may not know, themselves. As such, it wouldn't be a very useful bug report, whereas if the person who implemented the libxml bindings for PHP filed it, they could make it a whole lot more useful. Maybe a good fix for PHP (that wouldn't involve the libxml people) would be to use a different XML parsing engine. Maybe use the HTML rendering engine that Firefox uses - Gecko. -- Edit this bug report at http://bugs.php.net/?id=47209edit=1
#47117 [Fbk-Bgs]: wrong XML parse, loss chars
ID: 47117 Updated by: rricha...@php.net Reported By: dir at melbis dot com -Status: Feedback +Status: Bogus Bug Type: DOM XML related Operating System: FreeBSD 7.1 PHP Version: 5.2.8 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. duplicate of bug #45996 Previous Comments: [2009-01-22 13:29:27] dm at vfh dot de I solved the problem by downgrading libxml2 from 2.7.2 to 2.6.32. See also: http://bugs.php.net/bug.php?id=45996 [2009-01-15 19:23:48] j...@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ [2009-01-15 17:24:28] dir at melbis dot com Description: When parsing XML, chars and was gone... For sample, Tag has lt;STRONGgt;, but outside wrong value: STRONG, must be STRONG Reproduce code: --- $data = 'MELBISSHOP Version=5.4.0DO KeyValues=1242descrlt;STRONGgt;/descr/DO/MELBISSHOP'; $xml_parser = xml_parser_create('UTF-8'); xml_set_element_handler($xml_parser, start_xml_tag, end_xml_tag); xml_set_character_data_handler($xml_parser, xml_tag); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE); xml_parse($xml_parser, $data, true); function start_xml_tag($mParser, $mName, $mAttrs) { global $gDoValues, $gCurrentTagName; $gCurrentTagName = $mName; if ( $mName != 'DO' ) { $gDoValues[$gCurrentTagName] = ''; } else { $gDoValues = array(); } } function xml_tag($mParser, $mData) { global $gDoValues, $gCurrentTagName; $gDoValues[$gCurrentTagName] .= $mData;} function end_xml_tag($mParser, $mName) { global $gDoValues, $gData; if ($mName == 'DO') { print_r($gDoValues); }} Expected result: Array ( [descr] = STRONG ) Actual result: -- Array ( [descr] = STRONG ) -- Edit this bug report at http://bugs.php.net/?id=47117edit=1
#47108 [Opn-Bgs]: 0xAE breaks DOMDocument's loadHTML
ID: 47108 Updated by: rricha...@php.net Reported By: terrafr...@php.net -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Windows XP PHP Version: 5.2.8 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Thats how its handled by libxml2 Previous Comments: [2009-01-15 17:54:01] terrafr...@php.net That makes sense. I updated the script to iterate through the problem characters and the ones you mentioned are included. Other problem characters include 0x26, 0x3C, 0x3E, 0xA4, 0xA5 and 0xAA. The first three make sense - they correspond to , , and , respectively. The latter three don't make as much sense to me. Also, it seems to me that it ought to fail more gracefully than it does - you wouldn't expect your browser to ignore all HTML after an invalid character is encountered and it seems to me like this shouldn't, either. Per your suggestion, I've filed a bug report on libxml2 here: http://bugzilla.gnome.org/show_activity.cgi?id=567885 Not sure if that's the appropriate bug tracker, though. Also, it seems like reproducing the bug using the language libxml2 is intended as a library for would be prudent, but alas, I don't have any C/C++ compilers on this computer. [2009-01-15 02:53:45] typoon at gmail dot com The explanation to this might be the fact that ISO-8859-7 does not have the character 0xAE. When libxml tries to convert it, an error is thrown because of this. References: http://www.itscj.ipsj.or.jp/ISO-IR/227.pdf http://en.wikipedia.org/wiki/ISO_8859-7 Checking the PDF you will see 0xAE is not assigned. Quoting wikipedia: Code values 001F, 7F, 809F, AE, D2 and FF are not assigned to characters by ISO/IEC 8859-7. More information and other reference can also be found on google. My 2 cents then are that this is not a bug at all. If you still think it is, the we might need to open a bug report for the libxml team as this is an error generated inside libxml, not PHP. Regards, Henrique [2009-01-14 20:08:27] terrafr...@php.net Description: All HTML after chr(0xAE) (if present) is ignored by DOMDocument's loadHTML(), even if chr(0xAE) is a valid character per the HTML's charset. In the Reproduce code, replace chr(0xAE) with chr(0xAF) or chr(0xAD) or just remove it all together, and it works. Further, if you echo out $str and copy / paste the HTML into validator.w3.org, it's valid HTML, even with the chr(0xAE). Reproduce code: --- ?php $str = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html head meta http-equiv=content-type content=text/html; charset=iso-8859-7 titletest/title /head bodypa' . chr(0xAE) . 'z/p/body /html'; $xml = new DOMDocument(); $xml-loadHTML($str); echo $xml-saveHTML(); Expected result: a#65533;z Actual result: -- Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: input conversion failed due to input error, bytes 0xAE 0x7A 0x7A 0x7A in C:\htdocs\test.php on line 14 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: input conversion failed due to input error, bytes 0xAE 0x7A 0x7A 0x7A in C:\htdocs\test.php on line 14 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlCheckEncoding: encoder error in Entity, line: 4 in C:\htdocs\test.php on line 14 Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: input conversion failed due to input error, bytes 0xAE 0x7A 0x7A 0x7A in C:\htdocs\test.php on line 14 a -- Edit this bug report at http://bugs.php.net/?id=47108edit=1