Skip to content

Commit

Permalink
Fix download filename with invalid headers (bug 1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Oct 4, 2011
1 parent 9910d7d commit 346c582
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gpodder/download.py
Expand Up @@ -772,7 +772,9 @@ def run(self):
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, \
Expand Down
6 changes: 6 additions & 0 deletions src/gpodder/model.py
Expand Up @@ -477,6 +477,12 @@ def local_filename(self, create, force_update=False, check_only=False,
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
Expand Down

0 comments on commit 346c582

Please sign in to comment.