From: info at smithfieldentertainment dot com Operating system: UNIX PHP version: Irrelevant PHP Bug Type: *Regular Expressions Bug description: ereg {0,255} limited to 255 ... and not documented
Description: ------------ I sent the following email to Mehdi Achour <[EMAIL PROTECTED]> --------------- Hi, I discovered (the hard way after hours of code troubleshooting) that ereg/eregi/etc. functions have a very useful but LIMITED length function. It seems that while the ereg functions will search for matches in (any?) length code, the length limiter {0, 255} is limited to 255. I was trying to match lengths of 350 and 800… but couldn’t figure out why I was getting an error. There’s no documentation on this anywhere that I could find. Please add it to all applicable regular expression match items that it applies to. Thanks! -- CJ Greiner [EMAIL PROTECTED] http://www.SmithfieldEntertainment.com 757-356-1166 Reproduce code: --------------- if (eregi("^([a-z0-9 $&*?\'.-]{100,300})$", $register_data[register_summary], $ereg_results) == FALSE) { $error_message .= '<br>Subject Summary: Please use only letters, numbers, and punctuation: \'-$&*?<br>'; } Expected result: ---------------- if the user input $register_data[register_summary] does not match the regular expression OR is ouside the acceptable length range of 100-300 letters, then the expression should return FALSE and assign an $error_message. Actual result: -------------- Even when the user input for $register_data[register_summary] had acceptable characters AND had acceptable lengths... The code failed because the max length of 300 {100, 300} was causing a FALSE or FAIL. I experimented with the length until I brought it down to 255... then it worked. This limit is not documented anywhere. There should be no limit... or at least a much higher limit, since the matching expression will work on a much longer string if no length limit is placed in it. Thanks! -- Edit bug report at http://bugs.php.net/?id=29039&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29039&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29039&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29039&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29039&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29039&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29039&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29039&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29039&r=support Expected behavior: http://bugs.php.net/fix.php?id=29039&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29039&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29039&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29039&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29039&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29039&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29039&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29039&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29039&r=float