Fix download filename with invalid headers (bug 1440)

This commit is contained in:
Thomas Perl 2011-10-04 10:36:43 +02:00
parent 9910d7d53a
commit 346c582fea
2 changed files with 9 additions and 1 deletions

View File

@ -772,7 +772,9 @@ class DownloadTask(object):
disposition_filename = get_header_param(headers, \
'filename', 'content-disposition')
if disposition_filename is not None:
# Some servers do send the content-disposition header, but provide
# an empty filename, resulting in an empty string here (bug 1440)
if disposition_filename is not None and disposition_filename != '':
# The server specifies a download filename - try to use it
disposition_filename = os.path.basename(disposition_filename)
self.filename = self.__episode.local_filename(create=True, \

View File

@ -477,6 +477,12 @@ class PodcastEpisode(PodcastModelObject):
ext = self.extension(may_call_local_filename=False).encode('utf-8', 'ignore')
if not check_only and (force_update or not self.download_filename):
# Avoid and catch gPodder bug 1440 and similar situations
if template == '':
logger.warn('Empty template. Report this podcast URL %s',
self.channel.url)
template = None
# Try to find a new filename for the current file
if template is not None:
# If template is specified, trust the template's extension