php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39154 HTTP digest auth example: incorrect regexp
Submitted: 2006-10-13 22:43 UTC Modified: 2006-11-03 17:07 UTC
From: thetrivialstuff at hotmail dot com Assigned: nlopess (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2006-10-13 22:43 UTC] thetrivialstuff at hotmail dot com
Description:
------------
In the Digest Authentication example on this page:

<http://ca3.php.net/manual/en/features.http-auth.php>

The regular expression used for splitting the auth header is missing at least one character. The script will fail if a url contains a question mark '?'. A fix is to change the preg_match_all line to be:

preg_match_all('@(\w+)=([\'"]?)([a-zA-Z0-9?=./\_-]+)\2@', $txt, $matches, PREG_SET_ORDER);

Reproduce code:
---------------
see <http://ca3.php.net/manual/en/features.http-auth.php>, digest auth example. copy & paste that code into a new file, then try to reach it with something like (example URL):

http://<your web server>/<file>.php?some=parameter

Expected result:
----------------
I expect the example URL above to authenticate as usual.

Actual result:
--------------
It will never authenticate, because the http_digest_parse() function returns false after failing to catch the "uri" parameter from the browser response.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-16 18:16 UTC] nlopess@php.net
my example, I'll take a look.
 [2006-11-03 17:07 UTC] nlopess@php.net
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.


 [2020-02-07 06:11 UTC] phpdocbot@php.net
Automatic comment on behalf of nlopess
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=8ab4410bc8795dd26f6f699fd8377dbd223eb2f8
Log: fix #39154: improve http digest auth regex
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Aug 03 08:00:03 2025 UTC