
On 11 Aug 2005, at 16:20, Elmar Germann wrote:
Hi Alastair,
We've just upgraded to OTRS 2.0.1, and we're seeing problems with the attachment support. Specifically, when we try to download or view attachments via the AgentTicketAttachment action, they get truncated. I've checked in the database with a test attachment and the lengths are correct there. Does anyone have any idea what might be wrong?
I can't explain why (seems to me like a bug in perl), but this patch fixed the problem at my installation:
otrs/Kernel/Output/HTML/Generic.pm 1701c1701,1702 < $Output .= "filename=\"$Param{Filename}\"\n"; ---
#$Output .= "filename=\"$Param{Filename}\"\n"; $Output .= "filename=\"".substr($Param{Filename}, 0, length ($Param{Filename}))."\"\n";
I think you've just put me on the right track, although I'm not convinced by your fix (I suspect you've inadvertently introduced a typo or perhaps commented out the "Content-Length:" line below.) Looking at a protocol trace, it's the Content-Length: header that is erroneous; commenting it out fixes the problem (although it isn't ideal because the Content-Length: header is useful). OK, it's as I thought... the length() function is computing a UTF-8 length, not a byte count; the fix is to change the line that says $Output .= "Content-Length: ".length($Param{Content})."\n"; to say $Output .= "Content-Length: ".bytes::length($Param{Content})."\n"; Everything seems to be working correctly after this change. Here's a unidiff: --- Generic.pm~ 2005-07-23 12:08:45.000000000 +0100 +++ Generic.pm 2005-08-11 17:12:42.000000000 +0100 @@ -1699,7 +1699,7 @@ $Output .= '; '; } $Output .= "filename=\"$Param{Filename}\"\n"; - $Output .= "Content-Length: ".length($Param{Content})."\n"; + $Output .= "Content-Length: ".bytes::length($Param{Content})."\n"; $Output .= "Content-Type: $Param{ContentType}\n\n"; # fix for firefox HEAD problem if (!$ENV{REQUEST_METHOD} || $ENV{REQUEST_METHOD} ne 'HEAD') { Kind regards, Alastair. -- http://www.alastairs-place.net