summaryrefslogtreecommitdiff
path: root/contrib/mw-to-git/git-remote-mediawiki.perl
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2014-04-23 14:34:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-04-23 22:22:54 (GMT)
commit9742fb7e53b2f3bd85b5f01e563aee2cad7e77b8 (patch)
treec179274f84a0f741099f018e1999588aecf504ef /contrib/mw-to-git/git-remote-mediawiki.perl
parent1c4ea83902e2a64472ccf99ced4ea773ad3dd8aa (diff)
downloadgit-9742fb7e53b2f3bd85b5f01e563aee2cad7e77b8.zip
git-9742fb7e53b2f3bd85b5f01e563aee2cad7e77b8.tar.gz
git-9742fb7e53b2f3bd85b5f01e563aee2cad7e77b8.tar.bz2
git-remote-mediawiki: fix encoding issue for UTF-8 media files
When a media file contains valid UTF-8, git-remote-mediawiki tried to be too clever about the encoding, and the call to utf8::downgrade() on the downloaded content was failing with Wide character in subroutine entry at git-remote-mediawiki line 583. Instead, use $response->decode() to apply decoding linked to the Content-Encoding: header, and return the content without attempting any charset decoding. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/mw-to-git/git-remote-mediawiki.perl')
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl7
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 3f8d993..8dd74a9 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -461,7 +461,12 @@ sub download_mw_mediafile {
my $response = $mediawiki->{ua}->get($download_url);
if ($response->code == HTTP_CODE_OK) {
- return $response->decoded_content;
+ # It is tempting to return
+ # $response->decoded_content({charset => "none"}), but
+ # when doing so, utf8::downgrade($content) fails with
+ # "Wide character in subroutine entry".
+ $response->decode();
+ return $response->content();
} else {
print {*STDERR} "Error downloading mediafile from :\n";
print {*STDERR} "URL: ${download_url}\n";