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

Bug #21177 XML_Util::collapseEmptyTags() can return NULL
Submitted: 2017-02-06 12:21 UTC
From: mpichot Assigned: ashnazg
Status: Closed Package: XML_Util (version 1.4.0)
PHP Version: 5.6.30 OS: Linux Centos 7
Roadmaps: (Not assigned)    
Subscription  


 [2017-02-06 12:21 UTC] mpichot (Malo Pichot)
Description: ------------ Fresh update of XML_Util v1.4.0 stable, create XML from string can return NULL in certain case : $ret = XML_Util::collapseEmptyTags("<id_mytest_yesorno></id_mytest_yesorno>"); => Return "<id_mytest_yesorno />" Correct $ret = XML_Util::collapseEmptyTags( "<idmytestyesorno></idmytestyesorno>"); => Return "<idmytestyesorno />" Correct $ret = XML_Util::collapseEmptyTags( "<id_mytest_yesorno />"); => Return NULL. Incorrect $ret = XML_Util::collapseEmptyTags( "<idmytestyesorno />"); => Return "<idmytestyesorno />" Correct I don't know why the regular expression does not match "<id_mytest_yesorno />", but it's not correct. Test script: --------------- $xml = "<id_mytest_yesorno></id_mytest_yesorno>"; echo(XML_Util::isValidName("id_mytest_yesorno").'='.XML_Util::collapseEmptyTags($xml).PHP_EOL); $xml = "<idmytestyesorno></idmytestyesorno>"; echo(XML_Util::isValidName("idmytestyesorno").'='.XML_Util::collapseEmptyTags($xml).PHP_EOL); $xml = "<id_mytest_yesorno />"; echo(XML_Util::isValidName("id_mytest_yesorno").'='.XML_Util::collapseEmptyTags($xml).PHP_EOL); $xml = "<idmytestyesorno />"; echo(XML_Util::isValidName("idmytestyesorno").'='.XML_Util::collapseEmptyTags($xml).PHP_EOL); Expected result: ---------------- 1=<id_mytest_yesorno /> 1=<idmytestyesorno /> 1=<id_mytest_yesorno /> 1=<idmytestyesorno /> Actual result: -------------- 1=<id_mytest_yesorno /> 1=<idmytestyesorno /> 1= 1=<idmytestyesorno />

Comments

 [2017-02-06 20:24 UTC] ashnazg (Chuck Burgess)
-Status: Open +Status: Verified -Assigned To: +Assigned To: ashnazg
 [2017-02-06 20:24 UTC] ashnazg (Chuck Burgess)
Verified this on PHP 5.5.x, though it works fine on 7.0.x.
 [2017-02-06 20:27 UTC] ashnazg (Chuck Burgess)
PR https://github.com/pear/XML_Util/pull/7 Malo, do you want to try out the fix before I merge it?
 [2017-02-06 20:37 UTC] ashnazg (Chuck Burgess)
-Status: Verified +Status: Feedback
 [2017-02-07 18:13 UTC] ashnazg (Chuck Burgess)
-Status: Feedback +Status: Closed
Fixed and released in v1.4.1.
 [2017-02-09 08:56 UTC] mpichot (Malo Pichot)
Hi Chuck, Sorry, I just see your comments now... It works fine for me :) Great job!