File::Find has an option untaint:
If find is used in taint-mode (-T command line switch or if EUID != UID or if EGID != GID) then internally directory names have to be untainted before they can be chdir'ed to. Therefore they are checked against a regular expression untaint_pattern.
The untaint option works as I expect under Linux, but I can't get it to work under Win32:
#!perl -T use strict; use warnings; use File::Find; use File::Spec::Functions; my $dir = undef; if ($^O eq q{MSWin32}) { $dir = catfile( qw ( C: src perl test untaint ) ); } else { $dir = catfile( qw ( / home foo test perl untaint ) ); } eval { find({ wanted => sub { print if -f; }, untaint => 1 }, $dir); }; print "find died:$@" if ($@); __END__ C:\src\perl\test\untaint>perl -lT ut.pl ut.pl find died:insecure cwd in find(depth) at C:/Perl/lib/File/Find.pm line + 747. C:\src\perl\test\untaint>perl --version This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 50 registered patches, see perl -V for more detail) Binary build 820 [274739] provided by ActiveState http://www.ActiveSta +te.com Built Jan 23 2007 15:57:46 $ perl -lT ut.pl ut.pl $ perl --version This is perl, v5.8.5 built for i386-linux-thread-multi
Is this a bug?
--
Andreas

In reply to File::Find untaint in taint-mode under Win32 by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.