Ovid has asked for the wisdom of the Perl Monks concerning the following question:
This substitutes the appropriate character code for either the ampersand or semicolon as it encounters it in the variable. I have to do both on the same line since the character codes themselves contain ampersands and semicolons and substituting for one would create false positives for the other is the other was substituted for later. While I'm rather proud of that regex (for a newbie), I have to admit that it's not terribly clear. Is there an easier way to scrub incoming data that will be tossed out to a Web page later on?s/(&|;)/($1 eq "&")?"& #38;":"& #59;"/ge;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Safer (and cleaner) way to print user-supplied text.
by btrott (Parson) on Jun 08, 2000 at 21:28 UTC | |
|
Re: Safer (and cleaner) way to print user-supplied text.
by cwest (Friar) on Jun 08, 2000 at 21:39 UTC | |
|
Re: Safer (and cleaner) way to print user-supplied text.
by swiftone (Curate) on Jun 08, 2000 at 21:48 UTC | |
|
Re: Safer (and cleaner) way to print user-supplied text.
by Ovid (Cardinal) on Jun 09, 2000 at 00:13 UTC | |
by BigJoe (Curate) on Jun 09, 2000 at 00:38 UTC | |
by Ovid (Cardinal) on Jun 09, 2000 at 00:58 UTC |