perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Chamas <jos...@chamas.com>
Subject Re: $Server->HTMLEncode, single quotes, and .pm files
Date Mon, 03 Jun 2002 23:05:52 GMT
Philip Mak wrote:
> 
> Perhaps this should be added to the $Server->HTMLEncode() regexp in
> ASP.pm?
> 
>         s/\'/&#039;/sg;
> 
> The reason is that the following code will not perform as expected:
> 
> print "<INPUT TYPE='TEXT' VALUE='".$Server->HTMLEncode("You're")."'>";
> 

Good reason.  I'll have this in 2.37 release, with ' escaped
to &#39; which seems to be supported well cross browser.  I drop
the 0 for efficiency only.

> Going off on a tangent, is it possible to do something like this in an
> XMLSub file (probably not valid Perl syntax, but it explains the
> idea):
> 
> for (qw(select text textarea)) {
>   sub $_ { $main::Response->Include("$_.inc", @_) }
> }
> 
> instead of manually typing:
> 
> sub select { $main::Response->Include('select.inc', @_) }
> sub text { $main::Response->Include('text.inc', @_) }
> sub textarea { $main::Response->Include('textarea.inc', @_) }
> ...

Right, I often have something like:

package my;
for (qw(select text textarea)) {
   eval "sub $_ { $main::Response->Include(\"$_.inc\", \@_) }"
}

but having XMLSubs all go to includes is sometimes overkill.

Obviously this points to a weakness in the system, to have to
do these things.  This might be better supported if all XMLSubs
are handled by one default subroutine as in:

sub XMLSubs_OnStart { }

or have some config like XMLSubsHandler my::handler

which would take as an argument the name of the XMLSubs tag
as one of its arguments as in:

sub my::handler {
  my($tagname, $args, $html) = @_;
  if($tagname =~ /^my:(select|text|textarea)$/) {
     $Response->Include("$_.inc", $args, $html);
  } else {
     die("cannot handle XMLSubs $tagname");
  }
}

My feeling is that some kind of global.asa subroutine would
be more ASPish than having the perl subroutine defined.
So this sub my::handler() could really be a XMLSubs_Handler
that if defined in the global.asa would take over the execution,
and the config for this might be just XMLSubsHandler 1

--Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

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


Mime
View raw message