You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Gerald Richter <ri...@ecos.de> on 2006/09/01 06:03:58 UTC

RE: Autoescaping using syntax modes

> 
> 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



 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Autoescaping using syntax modes

Posted by Gerald Richter <ri...@ecos.de>.
> 
> 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.
> 

Embperl works this way to allow local $escmode to work in normal pages. If
you change $escmode and reset it again, the reset will done after the first
output. That is exactly what you are seeing.

You could use $epreq -> component -> curr_esc_mode instead, but you have to
enable it in xsbuilder/maps/ep_structure.map (remove the ! At the start of
the line) and run xsbuilder/source_scan.pl and xsbuilder/xs_generate.pl.
Afterwards rebuild Embperl.

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Autoescaping using syntax modes

Posted by Trey Hyde <Ri...@cnet.com>.
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