Patches item #1574068, was opened at 2006-10-09 17:40
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1574068&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Scott Dial (geekmug)
>Assigned to: A.M. Kuchling (akuchling)
Summary: urllib2 - Fix line breaks in authorization headers

Initial Comment:
urllib2 uses the wrong base64 encode function from the
base64 library. This patch corrects that.

Original bug report from "The Doctor What"
<[EMAIL PROTECTED]>

I found a bug in urllib2's handling of basic HTTP
authentication.

urllib2 uses the base64.encodestring() method to encode the
username:password.

The problem is that base64.encodestring() adds newlines
to wrap the
encoded characters at the 76th column.

This produces bogus request headers like this:
---------->8---------cut---------8<----------------
GET /some/url HTTP/1.1
Host: some.host
Accept-Encoding: identity
Authorization: Basic
cmVhbGx5bG9uZ3VzZXJuYW1lOmFuZXZlbmxvbmdlcnBhc3N3b3JkdGhhdGdvZXNvbmFuZG9uYW5k
b25hbmRvbmFuZG9u

User-agent: some-agent
---------->8---------cut---------8<----------------


----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-10-27 13:14

Message:
Logged In: YES 
user_id=11375

Good fix -- applied to the trunk (rev. 52481) and 25-maint
(rev. 52482).  Thanks for the patch and for the bug report!

----------------------------------------------------------------------

Comment By: Christian H�ltje (docwhat)
Date: 2006-10-10 10:00

Message:
Logged In: YES 
user_id=267

Cool!  I'm glad my bug report helped. :-)

----------------------------------------------------------------------

Comment By: Scott Dial (geekmug)
Date: 2006-10-09 20:33

Message:
Logged In: YES 
user_id=383208

Ah yes, you are correct that urllib has the same problem. I
have attached a patch to correct all of those instances as well.

It is note-worthy that the one usage of decodestring in
urllib is correct (as it is decoding the body of the
response and should reasonably expect to see newlines in
that encoding).


----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2006-10-09 20:13

Message:
Logged In: YES 
user_id=261020

urllib should also be fixed.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1574068&group_id=5470
_______________________________________________
Patches mailing list
[email protected]
http://mail.python.org/mailman/listinfo/patches

Reply via email to