[Petal] Weird behaviour of encoded entities

Max Maischein corion at corion.net
Fri Nov 14 10:39:14 GMT 2003


Hello,

I've been dabbling with Petal a bit and like it, but there seems to be
some confusion (on my side) with how entities within templates are handled.

I've attached two files, a template and an according test file that
exhibits the weird behaviour with entities:

< remains encoded
&gt; gets turned into "<"
&nbsp; gets turned into &amp;nbsp;
&amp; remains encoded

Maybe it is something with my template, that I should have another
namespace or some <? > declaration there, but it confuses me to no end :-)

I haven't looked where the problem comes from programmatically, as I
think that the problem is more with my usage than with Petal itself :-)

-max

(I don't know whether the list accepts attachments. If not, I'll resend
the two files in a separate mail)




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webarch.co.uk/pipermail/petal/attachments/20031114/52fca6f2/666_entity_replace.htm
-------------- next part --------------
#!/usr/bin/perl -w
use strict;

my @entities;
use HTML::Entities;
BEGIN {
  @entities = ((map { encode_entities $_ } qw( < > & )), '&nbsp;');
};

use Test::More tests => 6;
BEGIN{ use_ok( Petal => '2.00' ); };

my $template = $0;
$template =~ s/\.t$/.tmpl/;
my $petal = Petal->new($template);
isa_ok( $petal, 'Petal' );

for my $entity (@entities) {
  like( $petal->process(), qr!<div>$entity</div>!, "$entity remains escaped" );
};



More information about the Petal mailing list