perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Mak <p...@animeglobe.com>
Subject $Server->HTMLEncode, single quotes, and .pm files
Date Sat, 01 Jun 2002 16:31:14 GMT
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")."'>";

It will become this:

<INPUT TYPE='TEXT' VALUE='You're'>

which is invalid HTML.

Here's why I ended up using single quotes instead of double quotes:

Single quotes are valid in HTML, and in Perl code it's useful to use
single quotes in 'print' statements. I couldn't use the <%= %>
notation because I was writing code in an XMLSub .pm file and the sub
was only a few lines long so I didn't want to $Response->Include.

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', @_) }
...

It just occured to me that I'm always using XMLSubs to generate HTML,
so it would be cleaner to write them in ASP style instead of Perl
style.

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


Mime
View raw message