Re: Apache::Request and parameters = 0
On Thu, 5 Oct 2000, John Reid wrote: Hi guys Has anyone any experience of passing a 0 as a parameter value through Apache::Request. I am passing a QUERY_STRING like ?param1=value1param2=0param3=value3. It appears that the 0 is being interpretted as an empty string. Is this a bug/expected behaviour or am I looking in completely the wrong area for the source of the problem? No its a bug. It also occurs if the QUERY_STRING is just 0 on its own. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
Re: Apache::Request and parameters = 0
Matt Sergeant wrote: On Thu, 5 Oct 2000, John Reid wrote: Hi guys Has anyone any experience of passing a 0 as a parameter value through Apache::Request. I am passing a QUERY_STRING like ?param1=value1param2=0param3=value3. It appears that the 0 is being interpretted as an empty string. Is this a bug/expected behaviour or am I looking in completely the wrong area for the source of the problem? No its a bug. It also occurs if the QUERY_STRING is just 0 on its own. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ ** In my limited experience, it is Perl in general that treats the value 0, in a query string as the empty string. In all of the scripts I have written, if 0 is possible as a param value, I have to explicity check for 0. In essence I agree with Matt, but wanted to pop that little piece of information in there in case it turns out to be pertinent... --Dana
Re: Apache::Request and parameters = 0
On Thu, 5 Oct 2000, Dana C. Chandler III wrote: In my limited experience, it is Perl in general that treats the value 0, in a query string as the empty string. In all of the scripts I have written, if 0 is possible as a param value, I have to explicity check for 0. This is only the case when you're going: if ($r-param('name')) { # do something } if its a zero then you should expect to be bitten in the ass by that one. However I do assume that there's similar code going on somewhere to turn the zero into undef. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
Re: Apache::Request and parameters = 0
Matt Sergeant wrote: On Thu, 5 Oct 2000, Dana C. Chandler III wrote: In my limited experience, it is Perl in general that treats the value 0, in a query string as the empty string. In all of the scripts I have written, if 0 is possible as a param value, I have to explicity check for 0. This is only the case when you're going: if ($r-param('name')) { # do something } if its a zero then you should expect to be bitten in the ass by that one. However I do assume that there's similar code going on somewhere to turn the zero into undef. Just to add, I was explicitly checking for 0 in the value returned but was getting an empty string. 0 in this case was a single character required. An empty string was not. Once Matt informed me it was a bug/feature it set my mind at ease and I was able to implement a work around. -- John Reid Senior Analyst/Programmer Open Connect (Ireland) Ltd http://www.openconnect.ie/
Re: Apache::Request and parameters = 0
Matt Sergeant wrote: On Thu, 5 Oct 2000, Dana C. Chandler III wrote: In my limited experience, it is Perl in general that treats the value 0, in a query string as the empty string. In all of the scripts I have written, if 0 is possible as a param value, I have to explicity check for 0. This is only the case when you're going: if ($r-param('name')) { # do something } if its a zero then you should expect to be bitten in the ass by that one. However I do assume that there's similar code going on somewhere to turn the zero into undef. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ ** Yes, in particular, $value = $r-param('name') || ""; this little snipit of code will bite you if the param is 0. I should have been more specific. --Dana
Re: Apache::Request and parameters = 0
On Thu, 5 Oct 2000, Dana C. Chandler III wrote: Yes, in particular, $value = $r-param('name') || ""; Or worse, $r-param('name') || "3"; # default but true Even I'm guilty of that one sometimes :-) -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
RE: Apache::Request and parameters = 0
-Original Message- From: Matt Sergeant [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 05, 2000 9:57 AM To: Dana C. Chandler III Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Apache::Request and parameters = 0 On Thu, 5 Oct 2000, Dana C. Chandler III wrote: Yes, in particular, $value = $r-param('name') || ""; Or worse, $r-param('name') || "3"; # default but true Even I'm guilty of that one sometimes :-) well, I suppose we are all guilty of that one... perl hubris to the extreme :) however, just for clarity, I don't see how this is a bug in Apache::Request (as you originally pointed out)... #!/usr/bin/perl use Apache::Request; my $r = Apache::Request-new(shift); my $value = $r-param('foo'); $r-send_http_header('text/plain'); print "foo: $value\n"; print "foo is undefined" unless defined $value; /perl-bin/foo.pl?foo=0 produces: foo: 0 which doesn't look like a bug to me. --Geoff -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
RE: Apache::Request and parameters = 0
On Thu, 5 Oct 2000, Geoffrey Young wrote: however, just for clarity, I don't see how this is a bug in Apache::Request (as you originally pointed out)... #!/usr/bin/perl use Apache::Request; my $r = Apache::Request-new(shift); my $value = $r-param('foo'); $r-send_http_header('text/plain'); print "foo: $value\n"; print "foo is undefined" unless defined $value; /perl-bin/foo.pl?foo=0 produces: foo: 0 which doesn't look like a bug to me. You're right... I was remembering something else: package FooTest; use Apache::Constants; use Apache::Reload; sub handler { my $r = shift; $r-send_http_header; print "Args: ", scalar $r-args, "\n"; return OK; } 1; Now send a request with the querystring 0 to that handler. I get: Args: No zero. $ENV{QUERY_STRING} contains the zero though. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
RE: Apache::Request and parameters = 0
-Original Message- From: Matt Sergeant [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 05, 2000 10:26 AM To: Geoffrey Young Cc: Dana C. Chandler III; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Apache::Request and parameters = 0 [snip] You're right... I was remembering something else: package FooTest; use Apache::Constants; use Apache::Reload; sub handler { my $r = shift; $r-send_http_header; print "Args: ", scalar $r-args, "\n"; return OK; } 1; Now send a request with the querystring 0 to that handler. I get: Args: No zero. $ENV{QUERY_STRING} contains the zero though. ok, I see that. Apache::Request seems to handle that condition fine, though. Something to keep in mind... --Geoff -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
RE: Apache::Request and parameters = 0
On Thu, 5 Oct 2000, Geoffrey Young wrote: package FooTest; use Apache::Constants; use Apache::Reload; sub handler { my $r = shift; $r-send_http_header; print "Args: ", scalar $r-args, "\n"; return OK; } 1; Now send a request with the querystring 0 to that handler. I get: Args: No zero. $ENV{QUERY_STRING} contains the zero though. ok, I see that. Apache::Request seems to handle that condition fine, though. I'm not sure I understand you since Apache::Request is just a subclass of Apache, it does exactly the same thing: use Apache::Request; sub handler { my $r = Apache::Request-new(shift); $r-send_http_header; print "Args: ", scalar $r-args, "\n"; return OK; } Outputs the same result. -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **
RE: Apache::Request and parameters = 0
-Original Message- From: Matt Sergeant [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 05, 2000 10:53 AM To: Geoffrey Young Cc: Dana C. Chandler III; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Apache::Request and parameters = 0 [snip] ok, I see that. Apache::Request seems to handle that condition fine, though. I'm not sure I understand you since Apache::Request is just a subclass of Apache, it does exactly the same thing: use Apache::Request; sub handler { my $r = Apache::Request-new(shift); $r-send_http_header; print "Args: ", scalar $r-args, "\n"; return OK; } Outputs the same result. oh, sorry... I meant using Apache::Request methods, like my @values = $r-param; -- Matt/ ** Director and CTO ** ** AxKit.com Ltd ** ** XML Application Serving ** ** http://axkit.org ** ** XSLT, XPathScript, XSP ** ** Personal Web Site: http://sergeant.org/ **