[BUG] html-encoding not always applied to "&" characters
Bruno Postle <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.petal |
|---|---|
| Message-ID | <[email protected]> |
The Petal docs say that, by default, ampersands (and some other
characters) are encoded to &
I have a case where this doesn't always happen; if I create a URI
object like so:
$document->{uri} = URI->new ("http://example.com/test.cgi?foo=test&bar=test");
..and use it in a template in two equivalent ways:
<p tal:content="string: ${uri}">stuff to be replaced</p>
<p tal:content="uri">stuff to be replaced</p>
..I get two different results (the second one is invalid XML):
<p>http://example.com/test.cgi?foo=test&bar=test</p>
<p>http://example.com/test.cgi?foo=test&bar=test</p>
--
Bruno
en.html
(text/html, 482 B)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:tal="http://purl.org/petal/1.0/"
xmlns="http://www.w3.org/1999/xhtml">
<head><title>A Test</title></head>
<body>
<p tal:content="string: ${uri}">stuff to be replaced</p>
<p tal:content="uri">stuff to be replaced</p>
<p tal:content="string: ${baz}">stuff to be replaced</p>
<p tal:content="baz">stuff to be replaced</p>
</body>
</html>
test.pl
(application/x-perl, 329 B)
#!/usr/bin/perl
use strict;
use warnings;
use Petal;
use URI;
my $document;
$document->{uri} = URI->new ("http://example.com/test.cgi?foo=test&bar=test");
$document->{baz} = "http://example.com/test.cgi?foo=test&bar=test";
my $template = new Petal (file => $ARGV[0], base_dir => '.');
print $template->process ($document);