This commit is contained in:
Kovid Goyal 2007-11-28 02:29:41 +00:00
parent 9236b5a05a
commit fea65749e6
2 changed files with 4 additions and 3 deletions

View File

@ -160,4 +160,4 @@ def sanitize_file_name(name):
Also remove path separators. ALl illegal characters are replaced by
underscores.
'''
return re.sub(r'[:\?\\\/]|^-', '_', name.strip())
return re.sub(r'[\|\~\:\?\\\/]|^-', '_', name.strip())

View File

@ -20,7 +20,8 @@ from urllib import url2pathname
from httplib import responses
from optparse import OptionParser
from libprs500 import __version__, __appname__, __author__, setup_cli_handlers, browser
from libprs500 import __version__, __appname__, __author__, setup_cli_handlers, \
browser, sanitize_file_name
from libprs500.ebooks.BeautifulSoup import BeautifulSoup
class FetchError(Exception):
@ -191,7 +192,7 @@ class RecursiveFetcher(object):
self.logger.debug('Error: %s', str(err), exc_info=True)
continue
c += 1
imgpath = os.path.join(diskpath, 'img'+str(c)+ext)
imgpath = os.path.join(diskpath, sanitize_file_name('img'+str(c)+ext))
self.imagemap[iurl] = imgpath
open(imgpath, 'wb').write(f.read())
tag['src'] = imgpath