in reply to Re: catching newlines from textarea input
in thread catching newlines from textarea input

you are right abigail-II: in my little following test sript, using input from textearea, the regex definetly works correctly as above. don't know what damm happens in my cms, have to look deeper in it's lines.
#!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; my $text = cleanup_txt( $query->param( 'text' )); if ( $text eq "") { cast_form(); } else { print "Content-type:text/html\n\n"; print ubb_txt( $text); } sub cleanup_txt { my $str = $_[0]; return "" unless ( defined $str ); $str =~ s/[<>"'&|]//gs; return $str; } sub cast_form { print "Content-type:text/html\n\n"; print "<html><head><title>test textearea</title></head>"; print "<body>\n<form method=post action=\cgi-bin/"; print "/red/\"><textarea rows=\"5\" cols=\"55\" name="; print "\"text\"></textarea><br><input type=\"submit\""; print " value='Submit' name=submit\" value='Submit' name="; print "\"submit\"></form></body></html>"; } sub ubb_txt { my $txt = shift; return "" unless ( defined $txt); my ($nl) = $txt =~ m{(\cM?\cJ)}; $txt =~ s{$nl$nl}{</p><p>}gs if (defined $nl); $txt =~ s{$nl}{<br>}gs if (defined $nl); return $txt; }