From 4edebf11a6eb893a7dea6aedd7565497b8907b6b Mon Sep 17 00:00:00 2001 From: xinming Date: Wed, 29 Jul 2009 05:10:29 +0000 Subject: Merge branch utf8_support branch (r1109:1112) into trunk. --- lib/Reaction/UI/LayoutSet.pm | 2 ++ lib/Reaction/UI/Window.pm | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Reaction/UI/LayoutSet.pm b/lib/Reaction/UI/LayoutSet.pm index a976d5b..1ebc646 100644 --- a/lib/Reaction/UI/LayoutSet.pm +++ b/lib/Reaction/UI/LayoutSet.pm @@ -55,6 +55,8 @@ sub has_layout { exists $_[0]->layouts->{$_[1]} }; sub _load_file { my ($self, $file, $build_args) = @_; my $data = $file->slurp; + utf8::decode($data) + unless utf8::is_utf8($data); my $layouts = $self->layouts; # cheesy match for "=for layout name ... =something" # final split group also handles last in file, (?==) is lookahead diff --git a/lib/Reaction/UI/Window.pm b/lib/Reaction/UI/Window.pm index 610a935..876a286 100644 --- a/lib/Reaction/UI/Window.pm +++ b/lib/Reaction/UI/Window.pm @@ -51,14 +51,22 @@ sub flush_events { foreach my $type (qw/query body/) { my $meth = "${type}_parameters"; my $param_hash = { %{$ctx->req->$meth} }; # yeah, FocusStack deletes it - $self->focus_stack->apply_events($param_hash) - if keys %$param_hash; + my @param_keys = keys %$param_hash; + if (@param_keys) { + for (@param_keys) { + utf8::decode($param_hash->{$_}) + unless (utf8::is_utf8($param_hash->{$_})); + } + $self->focus_stack->apply_events($param_hash); + } } }; sub flush_view { my ($self) = @_; my $res = $self->ctx->res; - $res->body($self->view->render_window($self)); + my $res_body = $self->view->render_window($self); + utf8::encode($res_body) if utf8::is_utf8($res_body); + $res->body($res_body); $res->content_type($self->content_type); }; -- cgit v1.2.3-54-g00ecf