perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trey Hyde <Richard.H...@cnet.com>
Subject RE: Autoescaping using syntax modes
Date Tue, 12 Sep 2006 18:18:05 GMT
On Fri, 2006-09-01 at 06:03 +0200, Gerald Richter wrote:

> > 
> > But I'm having a little trouble with textareas.
> > 
> > Given this input,
> > 
> > <textarea name="foo">test</textarea>
> > 
> > and 
> > 
> >     $self->AddTag("textarea", ["id", "name", "rows", "cols"], 
> > undef(), undef(),
> >   { perlcode => q{
> >       print STDERR 
> > "|".XML::Embperl::DOM::Node::iChildsText(%$n%)."|\n";
> >       _ep_rp(%$x%, 
> > $epreq->Escape(XML::Embperl::DOM::Node::iChildsText(%$n%), 5));
> >   }});
> > 
> 
> If I remeber right out of my head you should use perlcodeend => instead of
> perlcode => because the XML::Embperl::DOM::Node::iChildsText needs to run at
> the end of the textarea.
> 
> Gerald


FYI, it will probably be important to know that I'm running Apache
1.3.29 with Embperl 2.2.0.

I've changed my tact a bit, I'm specifying which tags I'd like contents
to be escaped on by doing the following inside of my syntaxmode.
  $self->AddTag("input", ["id", "name", "type", "value", "size",
"maxlength"], undef(), undef(),
		  { perlcode => 'local $escmode = 7;', 
         	     perlcodeend => 'local $escmode = 0;' }

This works very well, until I hit what looks like a scoping problem.

This code, 

[- $escmode = 0; -]
[+ "<html>" +]
<head><title>esc test</title>
</head>
<body>
Hello<br/>
<form action="POST">
<input name="foo" />
</form>
<br />
[+ "<world>" +]
[+ "</body>" +]
[+ "</html>" +]

produces

<html>

<head><title>esc test</title>
</head>
<body>
Hello<br/>
<form action="POST">
<input name="foo" />
</form>
<br />
&lt;world&gt;
</body>
</html>

I wasn't expecting to see the <world> escaped in such a way.  What is bizarre is that
this behavior only seems to affect the first [+ +] block.



This:

[- $escmode = 0; -]

[+ "<html>" +]
<head><title>esc test</title>
</head>
<body>
Hello<br/>
<form action="POST">
<input name="foo" />
</form>
<br />
Escmode [+ $escmode +]
[+ "<world>" +]
[+ "</body>" +]
[+ "</html>" +]



produces this.


<html>

<head><title>esc test</title>
</head>
<body>
Hello<br/>
<form action="POST">
<input name="foo" />
</form>
<br />
Escmode 0
<world>
</body>
</html>


This verifies (I believe) that my AddTag code isn't leaving $escmode in
some sort of strange state.    If I change the AddTag declaration to use
$escmode WITHOUT the local modifier, the same behavior happens.

Can anyone verify this is a bug or help me with a resolution?  Thanks.





________________________________________________________________________


Richard "Trey" Hyde 
Lead Software Engineer, CNET Channel
(949) 399 8722
Richard.Hyde@cnet.com
For technical support, please email channelsupport@cnet.com



Mime
View raw message