In situations like this, I always see if I can throw a buffer in between the user and the file system. From the information you provided, it sounds like these email templates already exist - so in your script, first read the directory containing the templates and record their names into a hash, with each value given a key such as the name of the file minus the extension (only works if they have the same extension, BTW).

Give the user the names of the keys(the aliases) , not the values (the actual file name).

Now you have created a buffer - instead of allowing the user to directly specify a file, and potentially put some nasty shell code in with it, they can only specify the alias of the file. The actually path is retrieved from the hash when the time comes to open the file.

This is just another way - it's a bit of over-kill, but it does work.

Jeff

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

In reply to (jeffa) Re: How do you clean up user specified filenames? by jeffa
in thread How do you clean up user specified filenames? by SilverB1rd

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.