From 891c8e49e6a52bb3bf88df6beea371054319ec95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= <danmichaelo@gmail.com> Date: Sun, 23 Nov 2014 20:02:42 +0100 Subject: [PATCH] [#65] File extension is not really needed --- mwclient/client.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/mwclient/client.py b/mwclient/client.py index 440d908..7db4b6e 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -514,15 +514,10 @@ class Site(object): # Workaround for https://github.com/mwclient/mwclient/issues/65 # ---------------------------------------------------------------- - # Since the filename in Content-Disposition is not used as the - # destination filename, we can pass in some ascii-only dummy name - # to make sure the server accepts it. - fname = 'upload' - name = getattr(file, 'name', None) - if name and name[0] != '<' and name[-1] != '>' and name.find('.') != -1: - ext = name[name.rfind('.') + 1:] - fname = 'upload.{}'.format(ext) - file = (fname, file) + # Since the filename in Content-Disposition is not interpreted, + # we can send some ascii-only dummy name rather than the real + # filename, which might contain non-ascii. + file = ('fake-filename', file) # End of workaround # ---------------------------------------------------------------- -- GitLab