Subject: | find_tempdir() still has problems under ms-windows |
Older CGI.pm versions had the following code in the find_tempdir sub:
if( $CGI::OS eq 'WINDOWS' ){
unshift @TEMP,
$ENV{TEMP},
$ENV{TMP},
$ENV{WINDIR} . $SL . 'TEMP';
}
This was problematic because it could put 'undef' values onto the @TEMP
array. This is fixed in 3.55 (and before) via the following:
# PeterH: These vars may not exist if this is invoked...
unshift(@TEMP,$ENV{TEMP}) if defined $ENV{TEMP};
unshift(@TEMP,$ENV{TMP}) if defined $ENV{TMP};
unshift(@TEMP,$ENV{WINDIR} . $SL . 'TEMP') if defined $ENV{WINDIR};
HOWEVER, this new code puts entries onto @TEMP in the opposite order of
the original code. The result is that C:\WINDOWS\TEMP will be preferred
over the settings from the environment variables, which is *not* what
most people will want. The order of the above three lines should be
reversed:
unshift(@TEMP,$ENV{WINDIR} . $SL . 'TEMP') if defined $ENV{WINDIR};
unshift(@TEMP,$ENV{TMP}) if defined $ENV{TMP};
unshift(@TEMP,$ENV{TEMP}) if defined $ENV{TEMP};
-----
An alternative fix would be to restore the old code and remove the other
'if defined' check that appears, and then change the line inside the loop:
for (@TEMP) {
do {$TMPDIRECTORY = $_; last} if -d $_ && -w _;
}
to
do {$TMPDIRECTORY = $_; last} if defined($_) && -d $_ && -w _;
Thanks!
-Jeff
PS: Yes, I am kind of ashamed of myself for using Perl with ms-win, but
I have no choice, I tellya, they've got my kids and won't release them
unless I cooperate !-)