Skip Menu |

This queue is for tickets about the Apache-Template CPAN distribution.

Report information
The Basics
Id: 105651
Status: open
Priority: 0/
Queue: Apache-Template

People
Owner: Nobody in particular
Requestors: troymore [...] nbnet.nb.ca
Cc:
AdminCc:

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



Subject: Content Length and UTF-8 Characters
Date: Fri, 3 Jul 2015 15:53:15 -0300
To: <bug-Apache-Template [...] rt.cpan.org>
From: "Troy Morehouse" <troymore [...] nbnet.nb.ca>
It appears that when setting: TT2Headers length And the resulting template contains UTF8 characters that have an ordinal value greater than 255, the resulting content gets truncated by intermediate proxies and or the client. On Chrome, the console dhows there error: <http://stackoverflow.com/questions/29894154/chrome-neterr-incomplete-chunke d-encoding-error> net::ERR_INCOMPLETE_CHUNKED_ENCODING By Setting: TT2Headers none appears to fix the problem. In Template::Apache::Service, I see that the length of the content is calculated by the perl "length" function. This function computes character length, rather than byte length. A simple fix would be: use Encode (); $r->headers_out->add('Content-Length' => length(Encode::encode_utf8($$content))) if $all or $headers->{ length };
Download winmail.dat
application/ms-tnef 4.9k

Message body not shown because it is not plain text.

On 2015-07-03 14:53:25, troymore@nbnet.nb.ca wrote: Show quoted text
> It appears that when setting: > > > > TT2Headers length > > > > And the resulting template contains UTF8 characters that have an ordinal > value greater than 255, the resulting content gets truncated by > intermediate proxies and or the client. On Chrome, the console dhows there > error: > > > > > > <http://stackoverflow.com/questions/29894154/chrome-neterr-incomplete-chunke > d-encoding-error> net::ERR_INCOMPLETE_CHUNKED_ENCODING > > > > > By Setting: > > > > TT2Headers none > > > > appears to fix the problem. > > > > In Template::Apache::Service, I see that the length of the content is > calculated by the perl "length" function. This function computes character > length, rather than byte length. A simple fix would be: > > > > use Encode (); > > > > $r->headers_out->add('Content-Length' => > length(Encode::encode_utf8($$content))) > > if $all or $headers->{ length }; >
This will be wrong if $$content contains characters between 128 and 255 and no utf8 flag is set.
Subject: RE: [rt.cpan.org #105651] Content Length and UTF-8 Characters
Date: Fri, 3 Jul 2015 17:45:05 -0300
To: <bug-Apache-Template [...] rt.cpan.org>
From: "Troy Morehouse" <troymore [...] nbnet.nb.ca>
I suppose one could do this then: use utf8; use Encode (); $r->headers_out->add('Content-Length' => length(utf8::is_itf8($$content) ? Encode::encode_utf8($$content) : $$content) ) if $all or $headers->{ length }; Or { use bytes; $r->headers_out->add('Content-Length' => length($$content)) if $all or $headers->{ length }; } Or something to that nature (i.e. bytes::length(...)) Show quoted text
-----Original Message----- From: Slaven_Rezic via RT [mailto:bug-Apache-Template@rt.cpan.org] Sent: July 3, 2015 5:33 PM To: troymore@nbnet.nb.ca Subject: [rt.cpan.org #105651] Content Length and UTF-8 Characters <URL: https://rt.cpan.org/Ticket/Display.html?id=105651 > On 2015-07-03 14:53:25, troymore@nbnet.nb.ca wrote:
> It appears that when setting: > > > > TT2Headers length > > > > And the resulting template contains UTF8 characters that have an ordinal > value greater than 255, the resulting content gets truncated by > intermediate proxies and or the client. On Chrome, the console dhows there > error: > > > > > > <http://stackoverflow.com/questions/29894154/chrome-neterr-incomplete-chunke > d-encoding-error> net::ERR_INCOMPLETE_CHUNKED_ENCODING > > > > > By Setting: > > > > TT2Headers none > > > > appears to fix the problem. > > > > In Template::Apache::Service, I see that the length of the content is > calculated by the perl "length" function. This function computes character > length, rather than byte length. A simple fix would be: > > > > use Encode (); > > > > $r->headers_out->add('Content-Length' => > length(Encode::encode_utf8($$content))) > > if $all or $headers->{ length }; >
This will be wrong if $$content contains characters between 128 and 255 and no utf8 flag is set.