Skip to content

Commit

Permalink
fixed inline template double encoding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 7, 2011
1 parent 161affe commit 0776a44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@ This file documents the revision history for Perl extension Mojolicious.

2.37 2011-12-07 00:00:00
- Improved unicode tests.
- Fixed inline template double encoding bug.

2.36 2011-12-05 00:00:00
- Changed default heartbeat timeout of Hypnotoad from 5 to 10
Expand Down
5 changes: 1 addition & 4 deletions lib/Mojolicious/Plugin/EPLRenderer.pm
Expand Up @@ -17,10 +17,7 @@ sub register {
# Template
my $inline = $options->{inline};
my $path = $r->template_path($options);
if (defined $inline) {
$inline = encode('UTF-8', $inline);
$path = md5_sum $inline;
}
$path = md5_sum encode('UTF-8', $inline) if defined $inline;
return unless defined $path;

# Cache
Expand Down
6 changes: 3 additions & 3 deletions t/mojolicious/lite_app.t
Expand Up @@ -228,7 +228,7 @@ get ':number' => [number => qr/0/] => sub {
};

# DELETE /inline/epl
del '/inline/epl' => sub { shift->render(inline => '<%= 1 + 1%>') };
del '/inline/epl' => sub { shift->render(inline => '<%= 1 + 1 %> ☃') };

# GET /inline/ep
get '/inline/ep' =>
Expand Down Expand Up @@ -925,7 +925,7 @@ $t->get_ok('/0',
$ENV{MOJO_REVERSE_PROXY} = $backup2;

# DELETE /inline/epl
$t->delete_ok('/inline/epl')->status_is(200)->content_is("2\n");
$t->delete_ok('/inline/epl')->status_is(200)->content_is("2\n");

# GET /inline/ep
$t->get_ok('/inline/ep?foo=bar')->status_is(200)->content_is("barworks!\n");
Expand All @@ -935,7 +935,7 @@ $t->get_ok('/inline/ep/too')->status_is(200)->content_is("0\n");

# GET /inline/ep/partial
$t->get_ok('/inline/ep/partial')->status_is(200)
->content_is(b("♥just ♥\nworks!\n")->encode);
->content_is("♥just ♥\nworks!\n");

# GET /source
$t->get_ok('/source')->status_is(200)->content_like(qr#get_ok\('/source#);
Expand Down

0 comments on commit 0776a44

Please sign in to comment.