The user input is going to be passed to the shell, I take it? It's certainly not safe to just escape semicolons and backticks. An ampersand has about the same effect as a semicolon, for example, and a pipe character will also cause another program to be launched. So is it safe to escape semicolons, backticks, ampersands, and pipes? Maybe; to know for sure you'd have to become an expert on a wide variety of shells and how they're launched from within perl, make sure none of the characters that effect the shell on any platform your script might run under are escaped, and bet the security of your application on your expertise being flawless. In Perl's spirit of laziness, that's probably not the best possible approach. :-)
Depending on what you want to do, there could be other options. If you use the multi-argument form of system or exec, shell characters aren't processed, so that's pretty safe. quotemeta is a fairly safe approach, too.
Of course, if you're not passing this data as arguments to a shell command, the rules are entirely different; whether they're easier or harder to work with depends on what you're doing with the data.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.