jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Upload: Use fake filename in MIME header
......................................................................
[FIX] Upload: Use fake filename in MIME header
The standard MIME request does only support ASCII characters in the
headers. As the value is apparently not interpreted it's replaced by
a dummy value, so Unicode characters in the file page name doesn't cause
pywikibot to receive an API error.
There is RFC2231 which is supported by both Python versions but not by
PHP on which the MediaWiki server rely (see bug: 73662). This does only
fix the uploads as it is unknown how to handle other MIME requests.
Bug: 73661
Change-Id: I5ea92dcf1115b675b56142494d805e75d389b7d4
---
M pywikibot/site.py
1 file changed, 4 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5b1399d..0093c79 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4460,6 +4460,8 @@
result = None
file_page_title = filepage.title(withNamespace=False)
if source_filename:
+ # TODO: Dummy value to allow also Unicode names, see bug 73661
+ mime_filename = 'FAKE-NAME'
# upload local file
# make sure file actually exists
if not os.path.isfile(source_filename):
@@ -4483,7 +4485,7 @@
mime_params={}, throttle=throttle)
req.mime_params['chunk'] = (chunk,
("application",
"octet-stream"),
- {'filename':
file_page_title})
+ {'filename': mime_filename})
if file_key:
req['filekey'] = file_key
try:
@@ -4518,7 +4520,7 @@
'mime_params': {
'file': (file_contents,
filetype.split('/'),
- {'filename': file_page_title})
+ {'filename': mime_filename})
}
}
req = api.Request(site=self, action="upload", token=token,
--
To view, visit
https://gerrit.wikimedia.org/r/174677
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ea92dcf1115b675b56142494d805e75d389b7d4
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Matanya <matanya(a)foss.co.il>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>