develooper Front page | perl.beginners | Postings from March 2002

RE: unallowed chars

Thread Previous | Thread Next
March 29, 2002 14:27
RE: unallowed chars
Message ID:

You raise a good point.

I wondered about that at the time I wrote the program and ran experiments to
see if I was getting what I thought I wanted. I don't think my experiments
were as thorough as they should have been.

I'd thought the classes I set up, "<->", "{-}", and "[-]", only contained
the two characters shown. However, I now see on an ASCII chart that there
are some intervening characters which are included, too. I think I'll go
back and change the code to be more specific just so I don't leave a hidden
land mine for myself.

Thanks for catching that!


-----Original Message-----
From: John W. Krahn []
Sent: Friday, March 29, 2002 5:10 PM
Subject: Re: unallowed chars

John wrote:
> The incoming e-mail form variables from my web page are vetted through
> various tests before they're processed. The first thing I do is to
> all "<, >, {, }, [, ]" characters to either "(" or ")", as appropriate. My
> theory is that I don't want any HTML tags being taken in, and will gladly
> suffer whatever small degradation which might occur to someone's prose
> as a consequence. <g>
>         $user_body =~ tr/<->/(-)/;
>         $user_body =~ tr/{-}/(-)/;
>         $user_body =~ tr/[-]/(-)/;

You do realize that using a hyphen (-) in a character class creates a
range of characters.  tr/<->/(-)/ changes '<' to '(', '=' to '-' and '>'
to ')'.  tr/{-}/(-)/ changes '{' to '(', '|' to '-' and '}' to ')'.
tr/[-]/(-)/ changes '[' to '(', '\' to '-' and ']' to ')'.

use Perl;

To unsubscribe, e-mail:
For additional commands, e-mail:

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About