Subject: | change to decoded_content breaks utf8 data |
The attached patch adds a t/local/nonascii.* test that fails
on 1.22 and works on 1.20.
I needed to set the charset of the testserver to 'text/html;
charset=utf8', everything else still passes but that could be
an argument if needed.
This is distilled from the rt-3.6 testsuite where we test
custom field values and tickets with non-ascii subjects.
It appears to be related to the compressed data changes
that added in a decode_content call in place of the content
in 1.20
Thanks
-keivn
Subject: | mech.diff |
diff -urN WWW-Mechanize-1.22/t/local/log-server WWW-Mechanize-1.22.hack/t/local/log-server
--- WWW-Mechanize-1.22/t/local/log-server 2006-02-01 22:44:15.000000000 -0500
+++ WWW-Mechanize-1.22.hack/t/local/log-server 2007-04-23 18:32:17.000000000 -0400
@@ -50,7 +50,7 @@
%cat = map { $_ => 1 } (defined $q->param('cat') ? $q->param('cat') : qw( cat_foo cat_bar ));
my @categories = map { $cat{$_} ? "checked" : "" } qw( cat_foo cat_bar cat_baz );
$res = HTTP::Response->new(200, "OK", undef, sprintf($body,$location,$session,$query,@categories));
- $res->content_type('text/html');
+ $res->content_type('text/html; charset=utf8');
debug "Request " . ($r->uri->path || "/");
if ( $location eq '/quit_server') {
debug "Quitting";
diff -urN WWW-Mechanize-1.22/t/local/nonascii.html WWW-Mechanize-1.22.hack/t/local/nonascii.html
--- WWW-Mechanize-1.22/t/local/nonascii.html 1969-12-31 19:00:00.000000000 -0500
+++ WWW-Mechanize-1.22.hack/t/local/nonascii.html 2007-04-23 18:39:21.000000000 -0400
@@ -0,0 +1,14 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
+
+<title>Query Builder</title>
+</head>
+ <body id="comp-Search-Build">
+<form method="post" action="Build.html" name="BuildQuery">
+<input name="ValueOf'CF.{Ñ}'" size="20" />
+</form>
+ </body>
+</html>
diff -urN WWW-Mechanize-1.22/t/local/nonascii.t WWW-Mechanize-1.22.hack/t/local/nonascii.t
--- WWW-Mechanize-1.22/t/local/nonascii.t 1969-12-31 19:00:00.000000000 -0500
+++ WWW-Mechanize-1.22.hack/t/local/nonascii.t 2007-04-23 18:46:28.000000000 -0400
@@ -0,0 +1,26 @@
+#!perl
+
+use warnings;
+use strict;
+use Test::More tests => 5;
+use lib 't/local';
+use LocalServer;
+
+BEGIN { delete @ENV{ qw( http_proxy HTTP_PROXY ) }; }
+BEGIN {
+ use_ok( 'WWW::Mechanize' );
+}
+
+my $server = LocalServer->spawn( file => 't/local/nonascii.html' );
+isa_ok( $server, 'LocalServer' );
+
+my $agent = WWW::Mechanize->new;
+isa_ok( $agent, 'WWW::Mechanize', 'Created object' );
+$agent->quiet(0);
+
+$agent->get( $server->url );
+ok( $agent->success, 'Got some page' );
+
+# \321\202 is \x{442}
+$agent->field("ValueOf'CF.{\321\202}'", "\321\201");
+is($agent->value("ValueOf'CF.{\321\202}'"), "\321\201", "set utf value");