[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] Quoting body from a WWWboard posting



Thanks very much for the tip about Perl not needing < and > to be 
escaped. I thought your fix was very promising, but it didn't work 
because the text from the textarea has no <p>'s and no <br>'s. It 
does have an ascii 10 (Hex A) line break character where the typist 
has hit return. There is no special character where the text wraps on 
the screen.

So, I replaced the <p> with the line break character that I copied 
out of the saved message. Now the script puts my quote character 
after line breaks, but of course it doesn't look too good because the 
text still wraps, but doesn't have quote characters in front of the 
wrapped lines. My question now is, do textareas work differently on 
Unix? -  because this script on some web sites seems to work 
correctly.

This code is part of where the message text file is created:

  print "Message:<br>\n";
    print "<textarea COLS=50 ROWS=10 name=\"body\">\n";
    $FORM{'body'} =~ s/</&lt;/g;
    $FORM{'body'} =~ s/>/&gt;/g;
    $FORM{'body'} =~ s/"/&quot;/g;
    print "$FORM{'body'}\n";
    print "</textarea><p>\n";

It seems to expect the data receive from "submit" to  have <,> and "

Later, when a file is read into variables, is this:

     if ($FORM{'body'}) {
       $body = "$FORM{'body'}";
       $body =~ s/\cM//g;
       $body =~ s/\n\n/<p>/g;
       $body =~ s/\n/<br>/g;

       $body =~ s/&lt;/</g;
       $body =~ s/&gt;/>/g;
       $body =~ s/&quot;/"/g;
    }
    else {
       &error(no_body);
    }

    if ($quote_text == 1) {
       $hidden_body = "$body";
       $hidden_body =~ s/</&lt;/g;
       $hidden_body =~ s/>/&gt;/g;
       $hidden_body =~ s/"/&quot;/g;
    }


>>This is the code I thought I had identified as containing the 
>>problem, but one of my kind responders said I might need to post 
>>more code.
>>
>>if ($quote_text == 1) {
>>    @chunks_of_body = split(/\&lt\;p\&gt\;/,$hidden_body);
>>    foreach $chunk_of_body (@chunks_of_body) {
>>       @lines_of_body = split(/\&lt\;br\&gt\;/,$chunk_of_body);
>>       foreach $line_of_body (@lines_of_body) {
>>          print NEWFILE ": $line_of_body\n";
>>       }
>>       print NEWFILE "\n";
>>    }
>> }
>>
>>The split function never seems to find any &lt etc., or insert any 
>>colons, except at the beginning of the text.
>>
>>$hidden_body is set to $body when the posting is to contain a 
>>quote. $body comes from what someone has typed into a TEXTAREA on 
>>the previous posting. Here is the beginning of the program, as 
>>modified by me:
>
>[snip]
>2. In what I've quoted above from your message, there is one glaring 
>question: Is your intent to split on the string '&lt;p&gt;' or the 
>string '<p>'  ?? In HTML it's necessary to escape '<' & '>' so the 
>browser doesn't interpret them as part of HTML markup. But *not so* 
>in Perl. in Perl, your statements from above would be:
>
>	 @chunks_of_body = split(/<p>/,$hidden_body);
>		...
>	@lines_of_body = split(/<br>/,$chunk_of_body);
>
>if you are trying to split on the P or BR HTML elements.


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org