From: pim at highattention dot nl Operating system: CENTOS 6.3 x86_64 PHP version: 5.3.21 Package: XML related Bug Type: Bug Bug description:Regex in XML fails with brackets
Description: ------------ A couple of weeks ago, we upgraded php to 5.3.19. Eversince the following bug appears: When I try to get the regex out of a XML file, he only gives the last piece as result. <?xml version="1.0" encoding="utf-8" ?> <simplexml> <regex><![CDATA[/(^[a-zA-Z0- 9._-]+@[a-zA-Z0-9-]+.[a-zA-Z.]{2,5}\$)|^\$/i]]></regex> </simplexml> The result is ']{2,5}\$)|^\$/i': > FileHandler_Xml Object ( [_filename:protected] => [_parser:protected] => [_children:protected] => Array ( [regex] => FileHandler_Xml_Element Object ( [_cdata:protected] => ]{2,5}\$)|^\$/i [_attributes:protected] => [_children:protected] => ) ) [obj] => ) I use 'XML Parser' to parse the XML to the object above. I hope somebody can help me out with this problem? With kind regards, Pim Test script: --------------- public function addXml($xml){ $this->_parserMemory = array(); $parser = xml_parser_create( 'UTF-8' ); xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_set_element_handler($parser, "_xmlTagOpen", "_xmlTagClose"); xml_set_character_data_handler($parser, "_xmlCdata"); if (!xml_parse($parser, $xml)) { $this->_children = array(); $error_code = xml_get_error_code($parser); $error_string = xml_error_string($error_code); $current_line = xml_get_current_line_number($parser); $current_column = xml_get_current_column_number($parser); } unset($this->_parserMemory); xml_parser_free($parser); } protected function _xmlCdata($parser, $cdata) { if ( trim($cdata) != '' && count($this->_parserMemory)>1 ) { $obj = $this->getCurrentObject(); $obj->setValue($this->_xmlConvertValueFromString($cdata)); } } Expected result: ---------------- > FileHandler_Xml Object ( [_filename:protected] => [_parser:protected] => [_children:protected] => Array ( [regex] => FileHandler_Xml_Element Object ( [_cdata:protected] => /(^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+.[a- zA-Z.]{2,5}\$)|^\$/i [_attributes:protected] => [_children:protected] => ) ) [obj] => ) Actual result: -------------- The result is ']{2,5}\$)|^\$/i': > FileHandler_Xml Object ( [_filename:protected] => [_parser:protected] => [_children:protected] => Array ( [regex] => FileHandler_Xml_Element Object ( [_cdata:protected] => ]{2,5}\$)|^\$/i [_attributes:protected] => [_children:protected] => ) ) [obj] => ) -- Edit bug report at https://bugs.php.net/bug.php?id=64126&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64126&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64126&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64126&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64126&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64126&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64126&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64126&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64126&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64126&r=support Expected behavior: https://bugs.php.net/fix.php?id=64126&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64126&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64126&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64126&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64126&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64126&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64126&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64126&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64126&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64126&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64126&r=mysqlcfg