Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 7493
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: Nobody in particular
Requestors: chris [...] ex-parrot.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: CGI objects access global data
(Tested with v3.05 under apache on Linux.) Consider two scripts: # a use CGI; use Storable qw(nstore); my $q = new CGI(); nstore($q, "/tmp/stash"); print $q->header(-content_type => 'text/plain'), $q->self_url(); # b use CGI; use Storable qw(retrieve); my $q = new CGI(); my $q2 = retrieve("/tmp/stash"); print $q->header(-content_type => 'text/plain'), $q->self_url(), "\n", $q2->self_url(); Invoking a, then b, we get the results, http://host/path/a and then http://host/path/b http://host/path/b This is broken -- the latter should print http://host/path/a http://host/path/b The reason is the CGI::url() extracts information from $ENV. So q2 thinks that its URL is the URL under which the script was invoked, not the URL under which it was saved. (Why does it matter? Well, I came across this in a case where I wanted to stash some data to be able to reinvoke a script via POST later on. I can imagine other cases where the same thing might arise.) I guess the easiest fix is to save the bits of %ENV that matter in the CGI object, rather than accessing the global %ENV.
Download (untitled) / with headers
text/plain 1.5k
I'm sorry this ancient bug report didn't receive a reply through the bug tracker. From a code review, I suspect this issue report as since been resolved, and I recommend that this bug now be closed by in the bug tracker. If there is a continuing suspicion that the issue exists, please submit a Test::More style test cause that illustrates the issue. Thanks! Mark On Fri Aug 27 08:33:32 2004, guest wrote: Show quoted text
> (Tested with v3.05 under apache on Linux.) > > Consider two scripts: > > # a > use CGI; > use Storable qw(nstore); > my $q = new CGI(); > nstore($q, "/tmp/stash"); > print $q->header(-content_type => 'text/plain'), $q->self_url(); > > # b > use CGI; > use Storable qw(retrieve); > my $q = new CGI(); > my $q2 = retrieve("/tmp/stash"); > print $q->header(-content_type => 'text/plain'), $q->self_url(), "\n", > $q2->self_url(); > > Invoking a, then b, we get the results, > > http://host/path/a > > and then > > http://host/path/b > http://host/path/b > > This is broken -- the latter should print > > http://host/path/a > http://host/path/b > > The reason is the CGI::url() extracts information from $ENV. So q2 > thinks that its URL is the URL under which the script was invoked, not > the URL under which it was saved. > > (Why does it matter? Well, I came across this in a case where I wanted > to stash some data to be able to reinvoke a script via POST later on. > I can imagine other cases where the same thing might arise.) > > I guess the easiest fix is to save the bits of %ENV that matter in the > CGI object, rather than accessing the global %ENV.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.