Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'll bite.

package Acme::Unicorn::Horn::Blessed; use strict; use warnings; BEGIN { use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw (Exporter); @EXPORT = qw (horn); @EXPORT_OK = qw (); %EXPORT_TAGS = (); } =head1 NAME Acme::Unicorn::Horn::Blessed - A blessed horn of a unicorn untaints ev +erything =head1 SYNOPSIS use Acme::Unicorn::Horn::Blessed; $untainted = horn( $tainted ); $untainted = horn( $tainted, blessed => 0 ); =head1 DESCRIPTION I<A blessed horn of a unicorn untaints everything.> This module untaints everything. =head1 USAGE =head2 horn( tainted_variable, [options] ) Untaint a variable. my $untainted = horn( $tainted ); # if we want to make sure no hackers can harm us, use an 'unblessed +horn of a unicorn' my $untainted = horn( $tainted, blessed => 0 ); =cut sub horn { my $variable = shift; my %options = @_ if ( scalar @_ % 2 ); my $foo; if ( exists $options{ blessed } and not $options{ blessed } ) +{ $foo = undef; } else { ($foo) = ($variable =~ /^(.*)$/gs); } return $foo; } =head1 BUGS The obvious problems you will have with considering tainted va +riables as untainted. =head1 AUTHOR Bryan =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO perl(1). =cut 1;

Note: Untested. And no, I'm not uploading this.

    -Bryan

Update: It seems my untested code did have a flaw! Thanks ambrus++.


In reply to Re^2: What's your favourite method of untainting? by mrborisguy
in thread What's your favourite method of untainting? by Corion

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-24 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found