1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 12:12:34 +01:00

consider apparently long extensions as part of the filename

(#1516)
This commit is contained in:
Mike Fährmann 2021-05-02 21:15:50 +02:00
parent 2133f1d77f
commit bc868e7bb8
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 5 additions and 1 deletions

View File

@ -67,7 +67,7 @@ def nameext_from_url(url, data=None):
filename = unquote(filename_from_url(url))
name, _, ext = filename.rpartition(".")
if name:
if name and len(ext) <= 16:
data["filename"], data["extension"] = name, ext.lower()
else:
data["filename"], data["extension"] = filename, ""

View File

@ -148,6 +148,10 @@ class TestText(unittest.TestCase):
self.assertEqual(
f("http://example.org/v2/filename.ext?param=value#frag"), result)
# long "extension"
fn = "httpswww.example.orgpath-path-path-path-path-path-path-path"
self.assertEqual(f(fn), {"filename": fn, "extension": ""})
# invalid arguments
for value in INVALID:
self.assertEqual(f(value), empty)