You're sure '$tmp1' is safe? What if it's ' unlink "/etc/passwd"' and you later call the sub? (Ok, so if its Windows, what if its something equally horrible?). What if some evildoer replaces the file you're reading with evil things? Are you sure you want to call eval with quotes instead of block delimiters?

Update: Ok, I missed the qq, that just makes it a little trickier. What if $tmp1 is '@{[unlink "/"]}' ?

I don't see the need to call eval anyway, use a closure:

# I assume this is just an example, as '$c' and '@a' serve # no real purpose here my $sub; { my $tmp = $tmp1; # You could even skip assigning to '$tmp' if '$tmp1' # already 'enclosed' in another limited context $sub = sub { my $c = shift; my @a = ($tmp); return @a; }; }
More update: I see this doesn't account for eval'ing the substitutions you're making, but I would rethink those also, the way you are 'calling' the 'template::gettmplsub' sub it will not get executed anyway. (Hmm, I guess it will later...)

In reply to Re: Untainting known good data by runrig
in thread Untainting known good data by Cine

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.