#48836 [Ver->Csd]: Example for HTTP auth has bad regexp
| From: | rquadling@php.net | Date: | Wed, 08 Jul 2009 08:21:13 +0000 |
| Subject: | #48836 [Ver->Csd]: Example for HTTP auth has bad regexp | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2457@lists.php.net to get a copy of this message | ||
ID: 48836
Updated by: rquadling@php.net
Reported By: mike at silverorange dot com
-Status: Verified
+Status: Closed
Bug Type: Documentation problem
Operating System: Irrelevant
PHP Version: Irrelevant
Assigned To: rquadling
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-07-07 16:16:06] mike at silverorange dot com
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 this bug report at http://bugs.php.net/?id=48836&edit=1