[Bps-public-commit] r19692 - in Net-Google-Code/trunk: lib/Net/Google/Code/Role

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri May 15 10:59:54 EDT 2009


Author: sunnavy
Date: Fri May 15 10:59:52 2009
New Revision: 19692

Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm
   Net-Google-Code/trunk/t/02.issue.t

Log:
decode content before return from fetch

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm	Fri May 15 10:59:52 2009
@@ -2,6 +2,7 @@
 use Moose::Role;
 use Params::Validate ':all';
 use WWW::Mechanize;
+use Encode;
 
 has 'mech' => (
     isa     => 'WWW::Mechanize',
@@ -29,7 +30,10 @@
           . $url;
     }
     else {
-        return $self->mech->content;
+        my $content = $self->mech->content;
+# auto decode the content to erase HTML::Parser's utf8 warning like this:
+# Parsing of undecoded UTF-8 will give garbage when decoding entities
+        return decode( 'utf8', $content );
     }
 }
 

Modified: Net-Google-Code/trunk/t/02.issue.t
==============================================================================
--- Net-Google-Code/trunk/t/02.issue.t	(original)
+++ Net-Google-Code/trunk/t/02.issue.t	Fri May 15 10:59:52 2009
@@ -10,7 +10,8 @@
 use FindBin qw/$Bin/;
 use File::Slurp;
 
-my $content = read_file( "$Bin/sample/02.issue.html" );
+use Encode;
+my $content = decode( 'utf8', read_file( "$Bin/sample/02.issue.html" ));
 
 my $mock = Test::MockModule->new('Net::Google::Code::Issue');
 $mock->mock(



More information about the Bps-public-commit mailing list