Subject: | CGI.pm (VERSION 3.27): small not yet relevant bug in script_name |
Date: | Mon, 19 Mar 2007 15:48:59 +0100 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | Stephan Struckmann <struckma [...] uni-greifswald.de> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello Lincoln,
although writing to script_name is not official documented, the
script_name method seams to be a read-write-property of a cgi-object.
Unfortunately, then it makes a small mistake when setting this property.
Try:
#perl -de0
DB<1> use CGI;
DB<2> $c = new CGI;
DB<3> $c -> script_name ( 'new value' );
DB<4> print $c -> script_name () ;
CGI=HASH(0x842a1ac)
DB<5> x $c
0 CGI=HASH(0x842a1ac)
'.charset' => 'ISO-8859-1'
'.fieldnames' => HASH(0x8500380)
empty hash
'.parameters' => ARRAY(0x8500668)
empty array
'.script_name' => CGI=HASH(0x842a1ac)
-> REUSED_ADDRESS
'escape' => 1
'use_tempfile' => 1
Obviously the script_name was not set correctly. I would expect:
DB<4> print $c -> script_name () ;
new value
The method code is as follows:
#### Method: script_name
# Return the partial URL to this script for
# self-referencing scripts. Also see
# self_url(), which returns a URL with all state information
# preserved.
####
'script_name' => <<'END_OF_FUNC',
sub script_name {
my ($self,@p) = self_or_default(@_);
if (@p) {
$self->{'.script_name'} = shift;
} elsif (!exists $self->{'.script_name'}) {
my ($script_name,$path_info) = $self->_name_and_path_from_env();
$self->{'.script_name'} = $script_name;
}
return $self->{'.script_name'};
}
END_OF_FUNC
As far as I concern, it should be:
#### Method: script_name
# Return the partial URL to this script for
# self-referencing scripts. Also see
# self_url(), which returns a URL with all state information
# preserved.
####
'script_name' => <<'END_OF_FUNC',
sub script_name {
my ($self,@p) = self_or_default(@_);
if (@p) {
$self->{'.script_name'} = shift @p; # CHANGED LINE
} elsif (!exists $self->{'.script_name'}) {
my ($script_name,$path_info) = $self->_name_and_path_from_env();
$self->{'.script_name'} = $script_name;
}
return $self->{'.script_name'};
}
END_OF_FUNC
Respectfully,
Stephan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF/qLb8viug4UfhY8RAnuyAJ4xGwKk0C2JfvEYFlkw3C6N+SoEuQCfS/5V
gH1larXa/t7w8s+udVseUls=
=THw2
-----END PGP SIGNATURE-----
Message body not shown because it is not plain text.