Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6847 invoked by uid 1010); 30 Jan 2008 20:00:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 6831 invoked from network); 30 Jan 2008 20:00:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2008 20:00:46 -0000 Authentication-Results: pb1.pair.com header.from=news@ger.gmane.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php-php-dev@m.gmane.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain m.gmane.org designates 80.91.229.2 as permitted sender) X-PHP-List-Original-Sender: php-php-dev@m.gmane.org X-Host-Fingerprint: 80.91.229.2 main.gmane.org Linux 2.5 (sometimes 2.4) (4) Received: from [80.91.229.2] ([80.91.229.2:39894] helo=ciao.gmane.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/F5-14302-C47D0A74 for ; Wed, 30 Jan 2008 15:00:14 -0500 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1JKJ6I-0005a3-Nk for internals@lists.php.net; Wed, 30 Jan 2008 20:00:03 +0000 Received: from p54adc3a3.dip.t-dialin.net ([84.173.195.163]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 30 Jan 2008 20:00:02 +0000 Received: from k by p54adc3a3.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 30 Jan 2008 20:00:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: internals@lists.php.net Date: Wed, 30 Jan 2008 20:57:06 +0100 Lines: 32 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: p54adc3a3.dip.t-dialin.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (windows-nt) Cancel-Lock: sha1:XAfrBC1bQK3cxWy7n02ozGEiKt0= Sender: news Subject: Bug in pcre (pcre.backtrack_limit)? From: k@rl.pflaesterer.de ((Karl =?iso-8859-1?Q?Pfl=E4sterer?=)) Hi, when pcre.backtrack_limit is reached with preg_replace() the subject string gets truncated to a string of length zero. Here is a simple example (yes I know you shouldn't write a regexp like that but it is simplified from a real pattern a coworker used). ,----[ PHP5.3 ] | m58s03:~# php -r '$s = str_repeat("a", 9999);echo strlen(preg_replace("/a(.*?)b/", "\$1", $s)),"\n";' | 9999 | m58s03:~# php -r 'ini_set("pcre.backtrack_limit",10);$s = str_repeat("a", 9999);echo strlen(preg_replace("/a(.*?)b/", "\$1", $s)),"\n";' | 0 | m58s03:~# php -r '$s = str_repeat("a", 99998);echo strlen(preg_replace("/a(.*?)b/", "\$1", $s)),"\n";' | 0 | m58s03:~# php -i|grep pcre | pcre | pcre.backtrack_limit => 100000 => 100000 | pcre.recursion_limit => 100000 => 100000 | m58s03:~# php -v | PHP 5.3.0-dev (cli) (built: Jan 20 2008 20:59:20) | Copyright (c) 1997-2008 The PHP Group | Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies `---- The same happens with PHP 5.2.5. The pcre lib is the one shipped with PHP. KP