You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <gy...@laserlink.net> on 2001/01/23 16:09:03 UTC

FW: bug in mod_perl-1.24 & request->args & request->content

hi all...

I made a patch for this.  It may not be as neat as Doug's one liner, but
it's pretty much the same as CGI.pm and returns undef for the empty value
(which is consistent with libapreq)

for some reason I can't get it past the internal/taint test, though
(t/net/perl/taint.pl)

am I missing something major?  maybe taint.pl only worked because args() was
bad?

--Geoff

Index: Apache/Apache.pm
===================================================================
RCS file: /home/cvspublic/modperl/Apache/Apache.pm,v
retrieving revision 1.60
diff -u -r1.60 Apache.pm
--- Apache/Apache.pm    2000/12/20 08:07:34     1.60
+++ Apache/Apache.pm    2001/01/23 15:03:39
@@ -38,7 +38,15 @@
     my($wantarray,$string) = @_;
     return unless defined $string and $string;
     if(defined $wantarray and $wantarray) {
-       return map { Apache::unescape_url_info($_) } split /[=&;]/, $string,
-1;
+      my (@pairs) = split /[&;]/, $string;
+      my ($param, $value, @args) = ();
+      foreach my $pair (@pairs) {
+        ($param,$value) = split '=', $pair, 2;
+        $param = Apache::unescape_url_info($param);
+        $value = Apache::unescape_url_info($value);
+        push @args, ($param, $value);
+      }
+      return @args;
     }
     $string;
 }


> -----Original Message-----
> From: Marc Lehmann [mailto:pcg@goof.com]
> Sent: Monday, January 22, 2001 9:13 AM
> To: modperl@apache.org
> Subject: bug in mod_perl-1.24 & request->args & request->content
> 
> 
> Apache.pm documents two methods "args" and "content" that 
> should return
> argument => value pairs (when called appropriately). In fact, args is
> implemented as:
> 
>         return map { Apache::unescape_url_info($_) } split 
> /[=&;]/, $string, -1;
> 
> However, this might return an odd number of values, for 
> example for this url:
> 
>         httpurl?arg1&arg2=val2
> 
> I get (arg1 => "arg2", val2), which is not as documented.
> 
> This url format is often used for boolean arguments (CGI.pm creates an
> arg1 => "", while I would prefer arg1 => undef in this case).
> 
> So either the documentation or the implementation is in error. I would
> prefer if the implementation were in error ;)
> 
> -- 
>       -----==-                                             |
>       ----==-- _                                           |
>       ---==---(_)__  __ ____  __       Marc Lehmann      +--
>       --==---/ / _ \/ // /\ \/ /       pcg@opengroup.org |e|
>       -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
>     The choice of a GNU generation                       |
>                                                          |
> 

Re: FW: bug in mod_perl-1.24 & request->args & request->content

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 25 Jan 2001, Dave Rolsky wrote:

> On Thu, 25 Jan 2001, Doug MacEachern wrote:
> 
> > +            for ($key, $val) {
> > +                push @args, $_ ? Apache::unescape_url_info($_) : undef;
> shouldn't this be:
> 
> push @args, defined $_ ? Apache::unescape_url_info($_) : undef;

yep, thanks.
 
> ???
> 
> Or am I just missing something?

nope, my fault for writing code after midnight.


Re: FW: bug in mod_perl-1.24 & request->args & request->content

Posted by Dave Rolsky <au...@urth.org>.
On Thu, 25 Jan 2001, Doug MacEachern wrote:

> +            for ($key, $val) {
> +                push @args, $_ ? Apache::unescape_url_info($_) : undef;
shouldn't this be:

push @args, defined $_ ? Apache::unescape_url_info($_) : undef;

???

Or am I just missing something?


-dave

/*==================
www.urth.org
We await the New Sun
==================*/



Re: FW: bug in mod_perl-1.24 & request->args & request->content

Posted by Doug MacEachern <do...@covalent.net>.
> this passes all tests for me..

doh!  but probably behaves just like the one liner.  this should work..

Index: Apache/Apache.pm
===================================================================
RCS file: /home/cvs/modperl/Apache/Apache.pm,v
retrieving revision 1.60
diff -u -r1.60 Apache.pm
--- Apache/Apache.pm	2000/12/20 08:07:34	1.60
+++ Apache/Apache.pm	2001/01/25 08:07:21
@@ -38,7 +38,15 @@
     my($wantarray,$string) = @_;
     return unless defined $string and $string;
     if(defined $wantarray and $wantarray) {
-	return map { Apache::unescape_url_info($_) } split /[=&;]/, $string, -1;
+        my @args;
+        local $_;
+        for my $pair (split /[&;]/, $string) {
+            my($key,$val) = split '=', $pair, 2;
+            for ($key, $val) {
+                push @args, $_ ? Apache::unescape_url_info($_) : undef;
+            }
+        }
+        return @args;
     }
     $string;
 }


Re: FW: bug in mod_perl-1.24 & request->args & request->content

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 23 Jan 2001, Geoffrey Young wrote:

> hi all...
> 
> I made a patch for this.  It may not be as neat as Doug's one liner, but
> it's pretty much the same as CGI.pm and returns undef for the empty value
> (which is consistent with libapreq)
> 
> for some reason I can't get it past the internal/taint test, though
> (t/net/perl/taint.pl)
> 
> am I missing something major?  maybe taint.pl only worked because args() was
> bad?

this passes all tests for me..

Index: Apache/Apache.pm
===================================================================
RCS file: /home/cvs/modperl/Apache/Apache.pm,v
retrieving revision 1.60
diff -u -r1.60 Apache.pm
--- Apache/Apache.pm	2000/12/20 08:07:34	1.60
+++ Apache/Apache.pm	2001/01/25 07:57:28
@@ -38,7 +38,14 @@
     my($wantarray,$string) = @_;
     return unless defined $string and $string;
     if(defined $wantarray and $wantarray) {
-	return map { Apache::unescape_url_info($_) } split /[=&;]/, $string, -1;
+        my @args;
+        local $_;
+        for my $pair (split /[&;]/, $string) {
+            for (split '=', $pair) {
+                push @args, $_ ? Apache::unescape_url_info($_) : undef;
+            }
+        }
+        return @args;
     }
     $string;
 }