[Cascavel-pm] get/set com AUTOLOAD

Alceu R. de Freitas Jr. glasswalk3r em yahoo.com.br
Quarta Dezembro 28 10:00:20 PST 2005


--- Luis Campos de Carvalho
<monsieur_champs em yahoo.com.br> escreveu:

>   NÃO!!! Variáveis especiais tem escopo GLOBAL!!!
>   Você precisa usar programação defensiva (declare
> todas as suas variáveis especiais como "local"
> antes de começar a usar).
> 
>   Eu não tive tempo de olhar seu código.
>   Se isso não corrigir o problema, por favor me
> contate e me envie mais código.

Essa é uma função em que tive o mesmo problema. Não
testei com "local".

sub clean_taint {

    #untainting directories

    my $dir;
    my $regex;

    # test should be different for MS Windows
    ( $Config{osname} =~ /ms\s?win32/i )
        ? ( $regex = '(^[\w\_\-\\\:\.]+$)' )
        : ( $regex = '(^[\w\_\-\/\.]+$)' );

    foreach $dir ( 'datdir', 'startup_location',
'log_file' ) {

        if ( $config->get($dir) =~ /$regex/o ) {

# :TRICKY:12/07/2005:ARFJr: do not know why, but using
$1 inside the method call sets a undef value
            my $temp_val = $1;

            $config->set( $dir, $temp_val );

        } else {

            die "Invalid characters in $dir
parameter\n";

        }

    }

    # test against tainted filename

    if ( $config->get('update') =~ /(^[\w\-\_\.]+$)/ )
{

# :TRICKY:12/07/2005:ARFJr: do not know why, but using
$1 inside the method call sets a undef value
        my $temp_val = $1;

        $config->set( 'update', $temp_val );

    } else {

        die 'Invalid data in ' .
$config->get('update') . "\n";

    }

}


[]'s


Alceu Rodrigues de Freitas Junior
--------------------------------------
glasswalk3r em yahoo.com.br
http://www.imortais.cjb.net
-----------------------------------------------------------------------
A well-used door needs no oil on its hinges.
A swift-flowing stream does not grow stagnant.
Neither sound nor thoughts can travel through a vacuum.
Software rots if not used.
These are great mysteries -- The Tao Of Programming, 5.1


	



	
		
_______________________________________________________ 
Yahoo! doce lar. Faça do Yahoo! sua homepage. 
http://br.yahoo.com/homepageset.html 



Mais detalhes sobre a lista de discussão Cascavel-pm