Bug #64126 [Fbk->NoF]: Regex in XML fails with brackets
| From: | php-bugs at lists dot php dot net | Date: | Sun, 28 Aug 2016 04:22:27 +0000 |
| Subject: | Bug #64126 [Fbk->NoF]: Regex in XML fails with brackets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203616@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64126&edit=1
ID: 64126
Updated by: php-bugs@lists.php.net
Reported by: pim at highattention dot nl
Summary: Regex in XML fails with brackets
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: XML related
Operating System: CENTOS 6.3 x86_64
PHP Version: 5.3.21
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2016-08-17 18:59:21] cmb@php.net
I can't reproduce this issue with a simplified test script, see
<https://3v4l.org/4dcOo>.
If this issue still persists for you, please provide a minimal,
but complete and self-contained test script, and further info
about your environment (particularly relevant appear to be PHP
version, the value of XML_SAX_IMPL, and if that's "libxml", the
value of LIBXML_VERSION).
------------------------------------------------------------------------
[2013-02-01 15:31:09] pim at highattention dot nl
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 this bug report at https://bugs.php.net/bug.php?id=64126&edit=1