This
perl -pe 's/#.*$//'
now becomes
perl -Tpe 'BEGIN { $ENV{PATH} = "" } s/#.*$//'
Why? You don't want to run external commands, do you? perl -Tpe 's/#.*$//' runs fine as long as magic open doesn't try to open a pipe to a program. But if you happen to pass rm -rf * | as a filename, taint will abort the program.
Yes, but it can be anticipated by the person running the program.
How? By checking the expanded filenames manually? I pass my filter to a co-worker in good spirit. "What, she ran it on a filename that ended with pipe-char "|"? Shame on her! for not knowing better that that means it will magically run a shell progra.... with 2-argument ope....."
No, shame on you for not telling her.

Suppose you would give her 'rm', and tell her it removes all files you give it as arguments. Now she runs 'rm *', and suddenly all her directories are gone as well, because she happened to have a file called '-rf' in her directory. I think she has the right to blame you for not telling her the entire truth.

BTW, suppose you, and all the other people in this thread who agree with you, manage to eliminate magic open because it's too dangerous if someone runs a program using magic open with a shell expanded '*', what's next? Eliminate Getopt::*? Because that could also do unexpected things if such a program is run with a shell expanded '*'.

No, it is different. Once again, your example is an explicit call to unlink
You were talking about "other" programs unintentionally creating data (in this case, filenames) which could have unwanted effects, yet it somehow isn't serious enough to warrant enabling taint checking. I came with a similar example of an "other" program unintentionally creating data (in my case, input to the program) which could have unwanted effects. My point is that if your program relies on data which cannot be trusted, it should taint check that data. Whether it's because you're using magic open, unlink or something else.

In reply to Re^9: magic-diamond <> behavior -- WHAT?! by JavaFan
in thread magic-diamond <> behavior -- WHAT?! by repellent

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.