[Petal] Petal 0.84 released

Jean-Michel Hiver jhiver at mkdoc.com
Mon Feb 10 12:53:54 GMT 2003


> I think that there may be a problem with the bugfix that I submitted.
> It appears that Petal has already replaced the inline syntax in the
> attribute value with the PI syntax used internally before the attribute
> is XML encoded and written to the output.  After processing your
> meta-template I get the following for the 'input' element:
> 
> <input petal:attributes="value entry/&lt;?var
> name=&quot;configuration/get_identity_field_name&quot;?&gt;;" type="hidden"
> name="id" />

I'm starting to understand... for static attributes I've added the
following lines:

  $value =~ s/\&/&amp;/g;
  $value =~ s/\</&lt;/g;
  $value =~ s/\>/&gt;/g;
  $value =~ s/\"/&quot;/g;


> I need to track this down further.  I thought that the logic around
> the code that I added had already assured that the attribute was
> truly static, without interpolation operators, however I seem to
> have been mistaken ;-)

Hehe... that's becoming pretty hairy :-) I think I just figured out what
happens.

I think what happens is that Petal supports the 'Inline' syntax, i.e.
just typing <input type="$type" />.

During the canonicalization process this gets converted to
<input type="<?var name="type"?>">. (XHTML.pm, line 90)

Then it gets XML-escaped... <input type="&lt;?var name="type"?&gt;"> and
that makes it not working...

So basically the string which is XML-escaped needs to be tokenized
first. Each token that's not a <?var...?> needs to be XML encoded, and
the others needs to be left in place...

Wicked, Evil, Evil stuff! This is more and more smelling like a kludge,
but... ah well, I'm sure that once it'll be working no one will mind :-)


> By the way, there is another problem that comes up when you
> use petal:attribute to fill in meta-template petal:attribute commands
> with multiple placeholders.  Because the semicolon acts as a delimiter
> for petal:attribute, it must be backslash-escaped when using the 'string:'
> modifier in the meta-template. But, since the semicolon is escaped,
> it will not act as a delimiter in the resulting template!

Do you mean that Petal does NOT unescape the escaped semicolon in the
output? If that's so it might be a bug... need a test please!


> I first kluged my way around this by creating a hash value SC => ';'
> and replacing the semicolons with ${SC} in the meta-template.  Since
> then, I have written a 'qq:' modifier which calls 'string:'.  Petales
> expressions are interpolated, and backslash-escape sequences are
> expanded much like with Perl's qq{} operator.  More on this in a later
> post.

Please do.

Cheers,
-- 
Building a better web - http://www.mkdoc.com/
---------------------------------------------
Jean-Michel Hiver
jhiver at mkdoc.com  - +44 (0)114 255 8097
Homepage: http://www.webmatrix.net/



More information about the Petal mailing list