Mantis - Quercus
Viewing Issue Advanced Details
4974 minor always 03-02-12 09:17 01-05-13 23:22
nemostein  
nam  
normal  
closed  
fixed  
none    
none 4.0.34  
0004974: Regex PCRE recursion (balancing groups) isn't working as expected in Quercus
When using a regex with recursive matching "(?R)" the result isn't what is expected.

______________________________
How to reproduce:
Run the following snippet

$subject = "{a{b{c}d}e}";
preg_match_all("
/
    {(
        (?:
            [^{}] | (?R)
        )*
    )}
    
/ixsm", $subject, $matches);
print_r($matches);

______________________________
What was expected:

Array
(
    [0] => Array
        (
            [0] => {a{b{c}d}e} // The whole match
        )

    [1] => Array
        (
            [0] => a{b{c}d}e // The 1st group
        )

)

______________________________
What is the result:

Array
(
    [0] => Array
        (
            [0] => {a{b{c}d}e} // The whole match is OK!
        )

    [1] => Array
        (
            [0] => c}d}e // The 1st group isn't.
        )

)

______________________________

The main problem is that the balance died at firs occurrence of "}"
I'm using the Quercus bundle in the maven repository at:
http://caucho.com/m2/com/caucho/resin/4.0.23/ [^]

<dependency>
    <groupId>com.caucho</groupId>
    <artifactId>resin</artifactId>
    <version>4.0.23</version>
</dependency>

Notes
(0006145)
nam   
01-05-13 23:22   
php/4eq2
php/4eq3

Fixed for 4.0.34.