on Mon, 27 May 2002 14:31:04 GMT, [EMAIL PROTECTED] (Martin A. Hansen)
wrote: 

> my nice cgi forms works beautiful under konq on linux. but the
> windows machine generates ^M at the and of lines? this makes eval
> go fubar? how can i prevent this??? 

There seems to be a lot of confusion about the line separators in 
<textarea> fields in an HMTL-form (if that's what you are talking 
about). In the HTML 3.2 reference spec at 
        
        <http://www.w3.org/TR/REC-html32>

one reads about <textarea>:

        It is recommended that user agents canonicalize line endings to 
        CR, LF (ASCII decimal 13, 10) when submitting the field's 
        contents.

It seems that konq doesn't follow this recommendation, while the 
Microsoft IE 5.5 does.

Further confusion arises when representing these special characters in 
various ways: decimal, octal, hexadecimal, etc. The following table 
(Perl notation) illustrates this:

    Name Decimal Octal Hexadecimal ControlChar 
     CR    13    \015     \x0D         \cM
     LF    10    \012     \x0A         \cJ

Then, to confuse matters further, the "\n", aka 'newline' sequence 
comes in, which happens to be different on different platforms:

    Platform      Newline
    Unix/Linux    \cJ
    Mac           \cM
    DOS/Windows   \cM\cJ

So if you're on a Unix platform, and you get <textarea> data from a 
HTML 3.2 compliant browser, you're essentially hosed. You get DOS-style  
line endings, while you want Unix-style ones. (And maybe some Mac 
browsers return <textarea> results  with \cM line endings - I don't 
know).

In my opinion, to be on the safe side, you will always have to perform 
both the following substitutions:

    s/\cM\cJ/\n/g;
    s/\cM/\n/g;

when you receive data from a <textarea> form field. You may even have 
to do the reverse substitutions when you want to include default text.

-- 
felix

 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to