When running under mod_perl, TT prefers Apache::Util over
HTML::Entities. However, Apache::Util doesn't escape all entities.
Maybe it should be configurable what entity encoder to use. Or maybe
there should be two additional filters which explicitly use one of the
encoders rather than guessing which one to use.

Here is a little example script to demonstrate. Note the difference in
TT's output between command line and mod_perl:
-------------------------------------------------------------------------
#!/usr/bin/perl -w

use strict;
use Template;
use Apache::Util qw(:all);
use HTML::Entities;

print "ContentType: text/plain\n\n";

print "Template Toolkit (version: $Template::VERSION):\n";
my $data  = "\t".'�: [% "�" | html_entity %]'."\n";
   $data .= "\t".'<: [% "<" | html_entity %]'."\n";

my $tproc = Template->new();
$tproc->process(\$data, {
}) || die $tproc->error;
print "\n";

print "HTML::Entities (version: $HTML::Entities::VERSION):\n";
print "\t�: ", HTML::Entities::encode("�"), "\n";
print "\t<: ", HTML::Entities::encode("<"), "\n";
print "\n";

print "Apache::Util (version $Apache::Util::VERSION):\n";
print "\t�: ", Apache::Util::escape_html("�"), "\n";
print "\t<: ", Apache::Util::escape_html("<"), "\n";
print "\n";
-------------------------------------------------------------------------


Run from the command line, this produces:
-------------------------------------------------------------------------
ContentType: text/plain

Template Toolkit (version: 2.07):
        �: &eacute;
        <: &lt;

HTML::Entities (version: 1.13):
        �: &eacute;
        <: &lt;

Apache::Util:
Undefined subroutine &Apache::Util::escape_html called at
/home/lengerkeh/www/hosts/de/cgi-perl/rental/tt_html_entity.pl line 25.
-------------------------------------------------------------------------


Run under mod_perl (Apache::Registry) the output is:
-------------------------------------------------------------------------
Template Toolkit (version: 2.07):
        �: �
        <: &lt;

HTML::Entities (version: 1.13):
        �: &eacute;
        <: &lt;

Apache::Util (version 1.02):
        �: �
        <: &lt;
-------------------------------------------------------------------------



Reply via email to