Problem with RE in AbstractBasicAuthHandler

C

Catalin Marinas

Hi,

I was trying to use the HTTPBasicAuthHandler with an MS web server
requiring authentication (basic) but without success. I digged a bit
in the urllib2 module (python 2.3.4) and it turned out to be a problem
with the regular expression matching in the
AbstractBasicAuthHandler.http_error_auth_reqed() function. The
rx.match() cannot be used since it always matches from the beginning
of the string and the reply from my server had 2 more words in front
(Negotiate, NTLM, Basic realm="...").

The patch below fixes this by replacing match() with search():

==================================================================
--- urllib2.py-orig 2004-07-20 16:10:28.000000000 +0100
+++ urllib2.py 2004-07-20 16:29:34.000000000 +0100
@@ -631,7 +631,7 @@
# XXX could be multiple headers
authreq = headers.get(authreq, None)
if authreq:
- mo = AbstractBasicAuthHandler.rx.match(authreq)
+ mo = AbstractBasicAuthHandler.rx.search(authreq)
if mo:
scheme, realm = mo.groups()
if scheme.lower() == 'basic':
==================================================================

Thanks,

Catalin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,663
Latest member
josh5959

Latest Threads

Top