Skip Menu |

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

Report information
The Basics
Id: 45617
Status: resolved
Worked: 5 min
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: Brian.Rectanus [...] breach.com
Cc:
AdminCc:

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



Subject: Truncate filter bug
Date: Thu, 30 Apr 2009 17:04:21 -0700
To: bug-Template-Toolkit [...] rt.cpan.org
From: Brian Rectanus <Brian.Rectanus [...] breach.com>
The truncated filter does not handle $len smaller than length of $char. Instead a negative val is passed to the substr() offset and there are some interesting results ;) Maybe make length($char) the minimum (untested): sub truncate_filter_factory { my ($context, $len, $char) = @_; $len = 32 unless defined $len; $char = "..." unless defined $char; # Length of char is the minimum length $lchar = length $char; $len = $lchar if $len < $lchar; return sub { my $text = shift; return $text if length $text <= $len; return substr($text, 0, $len - $lchar)) . $char; } } later, -B -- Brian Rectanus Breach Security