perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Chamas <>
Subject Re: [IDEA] Automatic URL Encoding
Date Tue, 10 Jul 2001 19:09:17 GMT
Philip Mak wrote:
> Is it practical/efficient for Apache::ASP to automatically scan <A HREF>
> tags?
> I had an idea about an automatic URL Encoding option. The idea is that
> someone types "PerlSetVar URLEncode 1" in their httpd.conf. Then,
> Apache::ASP will automatically call $Server->URLEncode() on every <A HREF>
> tag.
> Applications that generate a lot of GET URLs would benefit from this, e.g.
> instead of:
> <a href="program.asp?param1=<%=$Server->URLEncode($param1)%>&amp;param2=<%=$Server->URLEncode($param2)">

Runtime parsing of content for something like this is very expensive.
For an example of how expensive, run a benchmark against an ASP 
page with SessionQueryParse turned on with sessions active, which 
splices session-id into URLs ( not just <a href=...> type too )

If this is a generally useful feature ( anyone else ? ) it may 
make sense to offer it as a config option as you suggest, and 
just do some runtime parsing, but I might otherwise recommend 
using XMLSubs for this.  Is there any precedent with other web
application platforms for this kind of functionality? 

Here's an example of how one might do this with XMLSubs

  PerlSetVar XMLSubsMatch a

in global.asa:

sub a { # something like this, untested
  my($args, $text) = @_;

  if(my $href = $args->{href}) {
    if($href =~ /\?/) {
	my($head,$tail) = split(/\?/, $href);
	my(@params) = split(/\&/, $tail);
	my @new_params;
	for my $param ( @params ) {
	  $param =~ s/\=(.*)/'='.$Server->URLEncode($1)/;
	  push(@new_params, $param);
	$args->{href} = $head."?".join('&', @new_params);        

  print "<a ".join(' ', map { "$_=$args->{$_}" } keys %$args).">$text</a>";


-- Josh

Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks <- Web Link Checking          Huntington Beach, CA  USA                1-714-625-4051

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message