Skip to content

Commit

Permalink
Fix download filename with invalid headers (bug 1440)
Browse files Browse the repository at this point in the history
Merged from the 'tres' branch.
  • Loading branch information
thp committed Oct 4, 2011
1 parent 8103217 commit 73ca508
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 @@ -746,7 +746,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 @@ -1017,6 +1017,12 @@ def local_filename(self, create, force_update=False, check_only=False,
return os.path.join(self.channel.save_dir, self.filename)

if self.filename is None or force_update or (self.auto_filename and self.filename == urldigest+ext):
# Avoid and catch gPodder bug 1440 and similar situations
if template == '':
log('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 73ca508

Please sign in to comment.