From b6b6f19a8d0ba8b99419e5819c15726623173364 Mon Sep 17 00:00:00 2001 From: Ian Dees Date: Sat, 9 Sep 2023 08:44:17 -0500 Subject: [PATCH 1/2] Use file extension from content disposition header instead of giving up --- openaddr/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openaddr/cache.py b/openaddr/cache.py index aac53f22..97108a12 100644 --- a/openaddr/cache.py +++ b/openaddr/cache.py @@ -207,8 +207,8 @@ def guess_url_file_extension(url): if path_ext == attachment_ext: _L.debug('Content-Disposition agrees: "{}"'.format(match.group('filename'))) else: - _L.debug('Content-Disposition disagrees: "{}"'.format(match.group('filename'))) - path_ext = False + _L.debug('Content-Disposition disagrees: "{}", using "{}" instead'.format(match.group('filename'), attachment_ext)) + path_ext = attachment_ext if not path_ext: # From 263afce59c2d236bf0d1e4d26263329d5af53eff Mon Sep 17 00:00:00 2001 From: Ian Dees Date: Sat, 9 Sep 2023 08:52:28 -0500 Subject: [PATCH 2/2] Use file extension from content-type instead --- openaddr/cache.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openaddr/cache.py b/openaddr/cache.py index 97108a12..f06f0ef3 100644 --- a/openaddr/cache.py +++ b/openaddr/cache.py @@ -207,8 +207,11 @@ def guess_url_file_extension(url): if path_ext == attachment_ext: _L.debug('Content-Disposition agrees: "{}"'.format(match.group('filename'))) else: - _L.debug('Content-Disposition disagrees: "{}", using "{}" instead'.format(match.group('filename'), attachment_ext)) - path_ext = attachment_ext + _L.debug('Content-Disposition disagrees: "{}" says we should use "{}", using "{}" instead'.format( + match.group('filename'), + attachment_ext, + path_ext, + )) if not path_ext: #