Forum Moderators: coopster & phranque

Message Too Old, No Replies

regex problems with GET chat system

need minimal filtering of chat text using regex

         

fabricator

2:13 pm on Oct 8, 2005 (gmt 0)

10+ Year Member



I need to use GET instead of POST (client limitations) and this creates problems with special characters entered into the chat client. So please no POST based examples.

the urls are in the form of....
chat.pl?text="some text?"
or perhaps even....
chat.pl?text="some%20text?"

Here is what I have so far, problem is it filters out the spaces in the text.

$text = param('text'); # Get text
$text =~ s/[^A-Za-z0-9_?]//g;

Commenting out the regex fixes that but creates other problems. Namely it leaves "" at the end of the string and puts newlines where there should be spaces, I think its to do with escape codes.

What I need is to keep every character bar newline. People often enter URLs, smilies etc into chat.

KevinADC

9:06 pm on Oct 8, 2005 (gmt 0)

10+ Year Member



Try this:

$text = param('text');
$text =~ s/[\n"]//g;

you might also want to look at the URI::Escape module

fabricator

3:51 am on Oct 9, 2005 (gmt 0)

10+ Year Member



Well that fixed it thanks.

Seems that because I print the input to a file then open it again to get other chatters text I don't need the escape module.