changeset 130:06a34c197b05

Added support for utf-8 and old versions of CGI module
author wizard
date Wed, 16 Jun 2010 01:50:56 +0400
parents e4f15cbc3f1a
children 3df87ee58bee
files Lib/IMPL/DOM/Transform/PostToDOM.pm Lib/IMPL/Web/Application.pm Lib/Mailer.pm
diffstat 3 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/PostToDOM.pm	Tue Jun 15 20:12:58 2010 +0400
+++ b/Lib/IMPL/DOM/Transform/PostToDOM.pm	Wed Jun 16 01:50:56 2010 +0400
@@ -20,7 +20,8 @@
     'IMPL::Transform' => sub {
     	-plain => \&TransformPlain,
         HASH => \&TransformContainer,
-        CGI => \&TransformCGI
+        CGI => \&TransformCGI,
+        CGIWrapper => \&TransformCGI
     }
 );
 
--- a/Lib/IMPL/Web/Application.pm	Tue Jun 15 20:12:58 2010 +0400
+++ b/Lib/IMPL/Web/Application.pm	Wed Jun 16 01:50:56 2010 +0400
@@ -75,7 +75,7 @@
 		my ($this) = @_;
 		return undef if $hasFetched;
 		$hasFetched = 1;
-		my $query = CGI->new();
+		my $query = CGIWrapper->new();
 		$query->charset($this->responseCharset);
 		return $query;
 	}
@@ -94,6 +94,26 @@
 	}	
 }
 
+package CGIWrapper;
+use base qw(CGI);
+
+use Encode;
+
+sub param {
+	my $this = shift;
+	
+	if (wantarray) {
+		my @result = $this->SUPER::param(@_);
+		
+		return map Encode::is_utf8($_) ? $_ : Encode::decode($this->charset,$_,Encode::LEAVE_SRC), @result;
+	} else {
+		my $result = $this->SUPER::param(@_);
+		
+		return Encode::is_utf8($result) ? $result : Encode::decode($this->charset,$result,Encode::LEAVE_SRC);
+	}
+
+}
+
 1;
 
 __END__
--- a/Lib/Mailer.pm	Tue Jun 15 20:12:58 2010 +0400
+++ b/Lib/Mailer.pm	Wed Jun 16 01:50:56 2010 +0400
@@ -1,4 +1,4 @@
-package Mailer;
+package IMPL::Mailer;
 use strict;
 
 use Encode qw (encode);