#38000 [Opn->Fbk]: preg_match fails if strlen >= 1630

From: Date: Tue, 04 Jul 2006 14:40:01 +0000
Subject: #38000 [Opn->Fbk]: preg_match fails if strlen >= 1630
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99083@lists.php.net to get a copy of this message
ID: 38000 Updated by: nlopess@php.net Reported By: dave at smartboy dot com -Status: Open +Status: Feedback Bug Type: PCRE related Operating System: Windows XP PHP Version: 5.1.4 New Comment: please provide the zzz file. (either post a link to it or send it to my e-mail). Previous Comments: ------------------------------------------------------------------------ [2006-07-04 00:46:02] dave at smartboy dot com Description: ------------ preg_match() with regexp to test for valid UTF-8 sequence - fails and causes the error message: 'Could not open input file: <name of script>.php' IF the subject string passed to preg_match() is longer than 1629 characters. (Or in this case the size of the file 'zzz' which contains ASCII) There was no such limitation in preg_match() in the previous version of PHP (5.1.2) Reproduce code: --------------- $str = file_get_contents('zzz'); echo "Loaded file...\n"; $result = preg_match('/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|' . '[\xe1-\xec][\x80-\xbf]{2}|\xed[\x80-\x9f][\x80-\xbf]|[\xee-\xef][\x80-\xbf]{2}|' . '\xf0[\x90-\xbf][\x80-\xbf]{2}|[\xf1-\xf3][\x80-\xbf]{3}|\xf4[\x80-\x8f][\x80-\xbf]{2})*$/S', $str) === 1; echo "Back from preg_match()\n"; var_export($result); echo "\n"; Expected result: ---------------- Loaded file... Back from preg_match() true Actual result: -------------- Loaded file... Could not open input file: u8.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38000&edit=1

« previous php.bugs (#99083) next »