#48836 [NEW]: Example for HTTP auth has bad regexp
| From: | mike at silverorange dot com | Date: | Tue, 07 Jul 2009 16:16:06 +0000 |
| Subject: | #48836 [NEW]: Example for HTTP auth has bad regexp | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2455@lists.php.net to get a copy of this message | ||
From: mike at silverorange dot com
Operating system: Irrelevant
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Example for HTTP auth has bad regexp
Description:
------------
The regular expression in the example on the HTTP authentication page
(http://php.net/manual/en/features.http-auth.php) is incorrect.
It seems from the comments on the page, a lot of developers are running
into problems trying to use the example.
Expected result:
----------------
The expression is correct. The subpattern for matching quoted values needs
to be non-greedy so it doesn't capture the whole auth string.
Here's a cleaned up and commented version of the expression that works:
preg_match_all(
'@
(\w+) # name
=
(?:
([\'"])([^\2]+?)\2 # quoted value
|
([^\s,]+) # unquoted value
)@x',
$txt, $matches, PREG_SET_ORDER);
--
Edit bug report at http://bugs.php.net/?id=48836&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48836&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48836&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48836&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48836&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48836&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48836&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48836&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48836&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48836&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48836&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48836&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48836&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48836&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48836&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48836&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48836&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48836&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48836&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48836&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48836&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48836&r=mysqlcfg