#48836 [Opn->Ver]: Example for HTTP auth has bad regexp

From: Date: Wed, 08 Jul 2009 08:06:57 +0000
Subject: #48836 [Opn->Ver]: Example for HTTP auth has bad regexp
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2456@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: Open +Status: Verified Bug Type: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant -Assigned To: +Assigned To: rquadling 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

« previous php.doc.bugs (#2456) next »