cuke4php icon indicating copy to clipboard operation
cuke4php copied to clipboard

cuke4php crashes on optional backreferences

Open mrtorrent opened this issue 14 years ago • 1 comments

Capture groups that create backreferences but are optional cause cuke4php to crash. For example:

/^the(?: losing)? code "([^"]*)"(?: has the prize "([^"]*)")?$/

The fourth capture group in this regex (the second ([^"]*)) causes cuke4php to crash because it is contained within a capture group that is optional. Note that the first and third capture groups are not an issue because they do not create backreferences (?:).

The crash can also be reproduced with a single, rather than nested, capture group which requires one or more characters but is optional as a whole, e.g. (.+)?

The resulting exception is:

PHP Fatal error: Uncaught exception 'PHPUnit_Framework_Error_Notice' with message 'Uninitialized string offset: 0' in /usr/lib/ruby/gems/1.8/gems/cuke4php-0.9.5/lib/Cuke4Php.php:204

mrtorrent avatar Aug 01 '11 16:08 mrtorrent

what version of PHP are you using? You might also try using the 0.9.6.c pre-release gem

olbrich avatar Aug 03 '11 01:08 olbrich