Skip Menu |
 

This queue is for tickets about the HTML-String CPAN distribution.

Report information
The Basics
Id: 92632
Status: open
Priority: 0/
Queue: HTML-String

People
Owner: Nobody in particular
Requestors: felliott [...] fiskur.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Catalyst::Plugin::Unicode::Encoding + HTML::String::TT skips encoding
Download (untitled) / with headers
text/plain 1024b
Hello, I had another issue with HTML::String::TT where it was causing my utf-8 characters to not be encoded before output. E.g. "ø" would be output as \xf8 instead of \xc3\xb8. I am using the encoding => 'UTF-8' option in my Catalyst config. The problem seems to be that on line 71 of Catalyst::Plugin::Unicode::Encoding is the following code: # Encode expects plain scalars (IV, NV or PV) and segfaults on ref's $c->response->body( $c->encoding->encode( $body, $CHECK ) ) if ref(\$body) eq 'SCALAR'; When I use HTML::String::TT with Catalyst::View::TT, then $c->response->body isa HTML::String::Value and the encoding is never done. I got around this by adding this to my View::TT subclass: around 'render' => sub { my $orig = shift; my $self = shift; my $res = $self->$orig(@_); return "$res"; }; Is this the correct way to solve this? If so, I'd be happy to contribute a doc patch. If not, what is the recommended way? Thank you and have a great day! Cheers, Fitz
Subject: Re: [rt.cpan.org #92632] Catalyst::Plugin::Unicode::Encoding + HTML::String::TT skips encoding
Date: Fri, 31 Jan 2014 19:32:17 -0800
To: "felliott [...] fiskur.org via RT" <bug-HTML-String [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Fri, Jan 31, 2014 at 06:11:10PM -0500, felliott@fiskur.org via RT wrote: Show quoted text
> # Encode expects plain scalars (IV, NV or PV) and segfaults on ref's > $c->response->body( $c->encoding->encode( $body, $CHECK ) ) > if ref(\$body) eq 'SCALAR'; > > When I use HTML::String::TT with Catalyst::View::TT, then $c->response->body isa HTML::String::Value and the encoding is never done.
It sounds like the code is really trying to check if the body is a single value or multiple values -- so it should *not* do the encoding if the ref is 'ARRAY', rather than *only* doing it when it's SCALAR (which doesn't catch blessed singular values). Show quoted text
> I got around this by adding this to my View::TT subclass: > > around 'render' => sub { > my $orig = shift; > my $self = shift; > my $res = $self->$orig(@_); > return "$res"; > };
That's a good workaround, but we're at fault here for checking the $body incorrectly. (I'm not in a position to do the fix though - someone more familiar with this code needs to agree with what I said.) :)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.