http://www.perlmonks.org?node_id=160083


in reply to proper untainting and use of ref

#!perl -T use strict; # !!!IN DEVELOPMENT ONLY!!! use warnings; # !!!IN DEVELOPMENT ONLY!!!

Good Lord! If you remove strict and warnings once this is in development then your script maintainer might forget about good programming practices later and do terrible things! I'd recommend leaving them in, even in production code.

As for why you have to untaint $userfile before you're allowed to write to it, I think you might want to look at these two lines:

sub CONFIG() { '../data/conf/site.conf' } my $config = do( CONFIG );
If your ../data/conf/site.conf file contains insecure data or anything that taint ought to object to, this will fail. For example if your conf script returns "$ENV{PATH}/userdirectories" (as it's last line) then $config will be tainted and when combined with the previously clean $param{username} will taint $userfile.

It would be sensible to untaint $config data too, just in case it changes. :) Nice code overall though. :)

Jarich

Update: Just read your Update and realised that you're right, it's not your configuration data. Did a few more tests and have decided that the problem is with taint not liking precompiled regular expressions. It all works as you'd expect if you replace your expressions with ordinary regular expressions. Unfortunately this sort of ruins the point. Any other suggestions monks?

I also missed a question. Yes, that's a good use of ref.