jpatokal / mediawiki-gateway

Ruby framework for MediaWiki API manipulation
Other
133 stars 50 forks source link

Character encoding error when uploading non-ASCII named files #20

Open jnv opened 13 years ago

jnv commented 13 years ago

Originally reported in #12

Using MRI 1.9.2-p290, when uploading files with name containing non-ASCII characters, the form_data.inspect (called via Logger#debug) raises a character encoding error:

incompatible character encodings: ASCII-8BIT and UTF-8
[...]/lib/media_wiki/gateway.rb:678:in `inspect'
[...]/lib/media_wiki/gateway.rb:678:in `make_api_request'
[...]/lib/media_wiki/gateway.rb:431:in `upload'

The actual line corresponds to my fork, in the current official tree it's 572

I was trying to #force_encoding("UTF-8") on all form_data items with no success, but I think the problem is somehow related to 'file' item (which is, as a File object for a binary file, ASCII-8BIT).

Currently the easiest workaround is to comment out the offending line.