summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormstenner <mstenner>2005-02-14 22:33:09 +0000
committermstenner <mstenner>2005-02-14 22:33:09 +0000
commitc6fc52157f46b898a640ab5d5128b0c9318b537f (patch)
tree7431e57ae17d38b3ec9f2a66f92469b9b0d7f9a4
parent94861d12f8137616ff19ead3f93c2205192aa6da (diff)
downloadurlgrabber-c6fc52157f46b898a640ab5d5128b0c9318b537f.tar.gz
Added http character encoding patch from Chris Lumens.
-rw-r--r--urlgrabber/grabber.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index ecf9596..da8009d 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -279,7 +279,7 @@ BANDWIDTH THROTTLING
"""
-# $Id: grabber.py,v 1.34 2005/02/14 21:55:07 mstenner Exp $
+# $Id: grabber.py,v 1.35 2005/02/14 22:33:09 mstenner Exp $
import os
import os.path
@@ -287,6 +287,7 @@ import urlparse
import rfc822
import time
import string
+import urllib
import urllib2
from stat import * # S_* and ST_*
@@ -570,7 +571,10 @@ class URLGrabber:
(url, parts) = self._parse_url(url)
(scheme, host, path, parm, query, frag) = parts
if filename is None:
- filename = os.path.basename( path )
+ if scheme in [ 'http', 'https' ]:
+ filename = os.path.basename( urllib.unquote(path) )
+ else:
+ filename = os.path.basename( path )
if scheme == 'file' and not opts.copy_local:
# just return the name of the local file - don't make a
# copy currently
@@ -662,6 +666,7 @@ class URLGrabber:
(scheme, host, path, parm, query, frag) = \
urlparse.urlparse(url)
path = os.path.normpath(path)
+ if scheme in ['http', 'https']: path = urllib.quote(path)
if '@' in host and auth_handler and scheme in ['http', 'https']:
try:
user_pass, host = host.split('@', 1)