The perlsec and perllocale documentation pages make it very clear that if a program does:

use locale;

Then untainting will not work if the regular expression used to untaint contains a character class - because under taint mode perl does not trust the locale information on the host system (if i understand correctly).

This makes sense, but what I can't find are any examples or documentation on the correct way to proceed when one wants to untaint text which may contain characters such as accented letters.

It sounds as if I somehow need to:
a) stop doing use locale
b) (re)define the common character classes such as \w myself to include things like accented characters

But I don't know how to do this, and i'm not really sure whether this is definitely the way to go.

Someone must have come across this problem previously. I would really appreciate your advice/guidence. It feels like I'm missing something fundamental

Surely many Perl web based applications have to untaint data that contains non english characters.

What is the correct secure way to untaint this data?


In reply to untainting and locales and internationalisation by Anonymous Monk

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.