in reply to Re^2: Tainting problem on Strawberry perl
in thread Tainting problem on Strawberry perl

I don't know why, sorry, but I can confirm it's probably a bug in your build. It doesn't affect my ActivePerl builds. I simplified your code to

use File::Spec::Win32; my $wdir = 'C:/strawberry'; $wdir =~ s[:][]g; $wdir =~ /(.*)/; print File::Spec::Win32->catfile('C:/cache', $1), "\n";

and I get (ActivePerl 5.8.8 & 5.10.0)

C:\cache\C\strawberry

You presumably get

C:\cache\C:

Replies are listed 'Best First'.
Re^4: Tainting problem on Strawberry perl
by EvanCarroll (Chaplain) on Feb 28, 2008 at 23:09 UTC
    Wow you found it, in that you made a test, I guess it has nothing to do with a being tainted, I'll rename node. That is correct with your code, I get what you've assumed I would get.


    Evan Carroll
    www.EvanCarroll.com

      Some more (speculation) on the subject:

      • $wdir =~ s[:][]g; can probably be removed from the test. I didn't want to remove too much, but I don't see how this could possibly trigger the bug. So really, the minimal test is probably

        use File::Spec::Win32; my $wdir = 'C/strawberry'; $wdir =~ /(.*)/; print File::Spec::Win32->catfile('C:/cache', $1), "\n";
      • The "C:" being appended probably comes from $cdir. The last regexp to successfully match in catfile is $path =~ s/^([a-z]:)/\u$1/s; (via canonpath via catdir), where path is a copy of $cdir.

        That would explain why $1 has been changed but not how it managed to get appended. I wouldn't mind having a look at your File/Spec/Win32.pm, specifically catfile.