in reply to Unlink under taint mode

I had another thought: does your code use locale? (I noticed that your location is Brazil.) Under use locale, perl -T won't trust /\w/ unless you specifically tell it so. For example, in your untaint you would use:

{ no locale; if ( $string =~ /([\w\-\_]+)/ ) { $clean_string = $1; } else { die "ilegal character: $!"; } }
See Laundering and Detecting Tainted Data in perlsec, and the SECURITY section of perllocale.

the lowliest monk

Replies are listed 'Best First'.
Right on the point!
by Andre_br (Pilgrim) on Apr 12, 2005 at 00:37 UTC
    Hey Postulant,

    Thatīs exactly the problem! Thanks a lot! I do use a specific locale. I had already managed to clean the $string out, with a pattern that didnīt have the \w and didnīt know why I succeeded. Thatīs it.

    By the way, Iīve found a simpler way to test if a variable is tainted, without having to use any extra module:

    if ( is_tainted($input) ) { die "tainted"; } else { die "not tainted"; + } sub is_tainted { return ! eval { join('',@_), kill 0; 1; }; }
    Thank you all!

    Take Care

    André