From:             5jpck6k02 at sneakemail dot com
Operating system: Linux
PHP version:      5.1.2
PHP Bug Type:     PCRE related
Bug description:  Can't include a literal plus sign in a character class

Description:
------------
A simple regular expression that has worked for years in PHP 4 
suddenly fails under PHP 5. 

Reproduce code:
---------------
foreach($_GET as $val)
        {
                if ( preg_match("/[^a-z0-9_\-\+]/i", $val) )
                {                       
                        die("<p>Invalid request.</p>");
                }
        }

Expected result:
----------------
The above code is used to filter out bogus GET requests 
containing potential XSS attacks at the top of a script. It 
should allow all legitimate requests comprised of alphanumeric 
characters, underscores, and plus and minus signs, through, 
while kicking anything containing a character not included in 
the character class out,

Actual result:
--------------
The regex matches plus signs contained in query strings even 
though the plus sign is explicitly included in the negated 
character class. I believe it is being interpreted as a 
quantifier when it is meant to be taken literally, I have not 
been able to find any means of successfully including a 
literal plus sign in a character class under PHP 5 to date. 

-- 
Edit bug report at http://bugs.php.net/?id=36703&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36703&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36703&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36703&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36703&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36703&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36703&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36703&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36703&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36703&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36703&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36703&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36703&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36703&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36703&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36703&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36703&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36703&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36703&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36703&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36703&r=mysqlcfg

Reply via email to