[Bug 565481] [NEW] PHP preg_match doesn't match matching string
Public bug reported: Binary package hint: php5 This regular expression: /^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/ matches this string: a:bbb in Perl (5.10.0-24ubuntu4): perl __END__ print 'a:b' =~ q/^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/; print \n; __END__ 1 and pcretest (libpcre3 7.8-3): pcretest __END__ /^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/ a:bbb __END__ PCRE version 7.8 2008-09-05 re data 0: a:bbb data Not, however, in PHP (php5-common 5.2.10.dfsg.1-2ubuntu6.4): php __END__ ?= preg_match(/^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/, a:b) ? __END__ 0 The bug is pretty sensible to changes in the input. Removing a couple of bs makes it match. I don't know which aspects of the regexp cause it to fail. For confirmation that this is indeed a bug without having to decypher the regexp, here's proof: ?php $A='(?:[^\[\]{}\']+|\'[^\']*\')+'; $a= 'a'; $B=:$A; $b= ':bbb'; print_r(preg_match(/^$A$/, $a)); print_r(preg_match(/^$B$/, $b)); print_r(preg_match(/^$A$B$/, $a$b)); print_r(\n); This outputs 110, which is impossible since if /^$A$/ matches $a and /^$B$/ matches $b, /^$A$B$/ should definitely match $a$b. I tried reporting this upstream, but bugs.php.net doesn't allow reporting bugs for versions earlier than 5.2.13. ProblemType: Bug Architecture: i386 Date: Sat Apr 17 19:11:27 2010 DistroRelease: Ubuntu 9.10 NonfreeKernelModules: nvidia wl Package: php5-common 5.2.10.dfsg.1-2ubuntu6.4 ProcEnviron: LANGUAGE=ca_ES.UTF-8 PATH=(custom, user) LANG=ca_ES.UTF-8 SHELL=/bin/bash ProcVersionSignature: Ubuntu 2.6.31-20.58-generic SourcePackage: php5 Uname: Linux 2.6.31-20-generic i686 ** Affects: php5 (Ubuntu) Importance: Undecided Status: New ** Tags: apport-bug i386 -- PHP preg_match doesn't match matching string https://bugs.launchpad.net/bugs/565481 You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to php5 in ubuntu. -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 565481] [NEW] PHP preg_match doesn't match matching string
Public bug reported: Binary package hint: php5 This regular expression: /^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/ matches this string: a:bbb in Perl (5.10.0-24ubuntu4): perl __END__ print 'a:b' =~ q/^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/; print \n; __END__ 1 and pcretest (libpcre3 7.8-3): pcretest __END__ /^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/ a:bbb __END__ PCRE version 7.8 2008-09-05 re data 0: a:bbb data Not, however, in PHP (php5-common 5.2.10.dfsg.1-2ubuntu6.4): php __END__ ?= preg_match(/^(?:[^\[\]{}']+|'[^']*')+:(?:[^\[\]{}']+|'[^']*')+$/, a:b) ? __END__ 0 The bug is pretty sensible to changes in the input. Removing a couple of bs makes it match. I don't know which aspects of the regexp cause it to fail. For confirmation that this is indeed a bug without having to decypher the regexp, here's proof: ?php $A='(?:[^\[\]{}\']+|\'[^\']*\')+'; $a= 'a'; $B=:$A; $b= ':bbb'; print_r(preg_match(/^$A$/, $a)); print_r(preg_match(/^$B$/, $b)); print_r(preg_match(/^$A$B$/, $a$b)); print_r(\n); This outputs 110, which is impossible since if /^$A$/ matches $a and /^$B$/ matches $b, /^$A$B$/ should definitely match $a$b. I tried reporting this upstream, but bugs.php.net doesn't allow reporting bugs for versions earlier than 5.2.13. ProblemType: Bug Architecture: i386 Date: Sat Apr 17 19:11:27 2010 DistroRelease: Ubuntu 9.10 NonfreeKernelModules: nvidia wl Package: php5-common 5.2.10.dfsg.1-2ubuntu6.4 ProcEnviron: LANGUAGE=ca_ES.UTF-8 PATH=(custom, user) LANG=ca_ES.UTF-8 SHELL=/bin/bash ProcVersionSignature: Ubuntu 2.6.31-20.58-generic SourcePackage: php5 Uname: Linux 2.6.31-20-generic i686 ** Affects: php5 (Ubuntu) Importance: Undecided Status: New ** Tags: apport-bug i386 -- PHP preg_match doesn't match matching string https://bugs.launchpad.net/bugs/565481 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs