From 5c6a3b828859eea7eb3fda24f38c38b87b54e9c1 Mon Sep 17 00:00:00 2001
From: Benjamin Mako Hill <mako@atdot.cc>
Date: Sat, 12 Feb 2011 19:34:54 -0500
Subject: fix bugs related to unicode handling

---
 lib/WWW/Mediawiki/Client.pm |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lib/WWW/Mediawiki/Client.pm b/lib/WWW/Mediawiki/Client.pm
index cfdc0a9..32a7d53 100644
--- a/lib/WWW/Mediawiki/Client.pm
+++ b/lib/WWW/Mediawiki/Client.pm
@@ -20,15 +20,6 @@ use Encode;
 use Encode::Guess;
 use utf8;
 
-BEGIN {
-    # If we tell LWP it's dealing with UTF-8 then URI::Escape will munge the text
-    # So either we put up with warnings or do this:
-    for (0x100 .. 0xd7ff, 0xf000 .. 0xfdcf) {
-        $URI::Escape::escapes{chr($_)} =
-        &URI::Escape::uri_escape_utf8(chr($_));
-    }
-}
-
 use base 'Exporter';
 our %EXPORT_TAGS = (
 	options => [qw(OPT_YES OPT_NO OPT_DEFAULT OPT_KEEP)],
@@ -1714,18 +1705,24 @@ sub _upload_file {
     my $act_name  = ($commit ? EDIT_SUBMIT_NAME  : EDIT_PREVIEW_NAME );
     my $act_value = ($commit ? EDIT_SUBMIT_VALUE : EDIT_PREVIEW_VALUE);
     my $url = $self->filename_to_url($filename, SUBMIT);
-    my $octets = Encode::encode($self->encoding, $text);
+    my $content_type = 'application/x-www-form-urlencoded;charset=' . 
+	$self->encoding;
+
     my $res = $self->{ua}->post($url,
-        [ 
+	'Content-type' => $content_type,
+	Content =>
+	[
             $act_name           => $act_value,
-            &TEXTAREA_NAME      => $octets,
+            &TEXTAREA_NAME      => $text,
             &COMMENT_NAME       => $self->{commit_message},
             &EDIT_TIME_NAME     => $self->{edit}->{date},
             &EDIT_TOKEN_NAME    => $self->{edit}->{token},
 	    @params,
-        ],
+        ]
     );
+
     my $doc = $res->decoded_content;
+
     my $headline = $self->_get_page_headline($doc);
     my $expect = ($commit ? $pagename : "Editing $pagename");
     unless (lc($headline) eq lc($expect)) {
-- 
1.7.2.3

