I was speaking with someone today on IRC who is experiencing a problem
with QUERY_STRING in Apache 2.0. If I correctly understand the
situation, QUERY_STRING getting sent as an empty string, rather than the
old behavior of just not setting it at all, is causing a strange
interaction with CGI.pm.

More explanation and a patch follows. I wondered if it might not be
better to just undef it, but I guess I'm not clear why this change was
made in the first place. Can someone elaborate on this for me?

Oh, and, ps, MasterCard loves Apache, and is ditching iPlanet in favor
of Apache. :-)

-- 
Rich Bowen - [EMAIL PROTECTED]
Apache Cookbook - http://www.oreilly.com/catalog/apacheckbk/

---------- Forwarded message ----------
Date: Mon, 11 Aug 2003 13:04:35 -0500
From: Sarah NameWithheldToProtectTheInnocent
To: [EMAIL PROTECTED]
Subject: apache 2.0.46 mastercard patch :)

file: util_script.c
line: 370
old line: apr_table_setn(e, "QUERY_STRING", r->args ? r->args : "");
new line: apr_table_setn(e, "QUERY_STRING", r->args ? r->args : " ");

Instead of undefing the parameter and dealing with all the possible
consequences of that, we redefined it as a space which seemed to
eliminate the quirky interaction with CGI.pm.  And, again the quirky
behavior appears in the sample code below when the param bug is
defined.

bash-2.03$ diff util_script.c mc_util_script.c
370c370
<     apr_table_setn(e, "QUERY_STRING", r->args ? r->args : " ");
---
>     apr_table_setn(e, "QUERY_STRING", r->args ? r->args : "");


#! /sys_apps_01/webadmin/bin/perl -T
# apache bug fun

use CGI;
$cgi = new CGI;

print $cgi->header();
print "<b>Normal 1:</b><br>";
showData($cgi);

if ($cgi->param("bug")) {
   $cgi2 = new CGI();
   print "<br><b>Bug!!!</b><br>";
}

$cgi = new CGI;

print "<br><b>Normal 2:</b><br>";
showData($cgi);

print "<br><b>Done</b>";
exit;

sub showData {
   my($cgi) = @_;

   foreach ($cgi->param()) {
      print "   $_ = " . $cgi->param("$_") . "<br>";
   }
}


Reply via email to