RE: cgi/Perl ... Removing literal CR's from textarea form submission.
by "Brian A. Sayrs" <sayrs(at)southwindsolutions.com>
|
| Date: |
Thu, 22 Jun 2000 07:51:13 -0700 |
| To: |
"'Peter Newton'" <c-newton(at)ihug.co.nz>, "hwg-techniques(at)hwg.org" <hwg-techniques(at)hwg.org> |
| |
todo: View
Thread,
Original
|
|
Hey, Peter,
You can't use tr/// (y/// for old timers) because it translates ONE character to ONE character. This is a job for s///
These two lines together will solve your problem:
$value =~ s/\r//g;
$value =~ s/\n/<BR>/g;
If you're putting together something which may show up on a web page somewhere, you might want to consider these as well:
this makes sure there aren't TOO many newlines in a row:
$value =~ s/\n{3,}/\n\n/gos;
these next two together ensures that the angle braces are not misunderstood by the browser, and disables HTML at the same time:
$value =~ s/</</g;
$value =~ s/>/>/g;
HTH,
Brian A. Sayrs
Owner, Southwind Solutions
-----Original Message-----
From: Peter Newton [SMTP:c-newton(at)ihug.co.nz]
Sent: Wednesday, June 21, 2000 6:40 PM
To: hwg-techniques(at)hwg.org
Subject: cgi/Perl ... Removing literal CR's from textarea form submission.
Hello all,
Thanks for all the good tips on flash4 detection, After all
that I went to download the program and it crashes with that
"This program has performed an illegal operation" error
message. No one seems to want to assist so I'll have to
shelve it for the moment.
My problem now is that I'm receiving forms from my website
which contains textarea inputs, however if anyone puts in a
literal CR in this field it mucks up my perl program which
filters the forms. One solution is to convert any literal
CR's into BR tags but I'm having trouble trying to detect a
literal CR. using tr/ / / or s/ / /g.
Can anyone help.?
Many Thanks
Peter Newton
-------------------------------------------------
Whats on in New Zealand?
go to http://nzsc.co.nz/
Who is on the net NEAR YOU?
go to http://nzsc.co.nz/
-------------------------------------------------
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.