Re: string length and newlines
- From: Bart Van der Donck <bart@xxxxxxxxxx>
- Date: Wed, 16 Jan 2008 02:34:30 -0800 (PST)
Steve Swift wrote:
Bart Van der Donck wrote:
Checking on a separate CR or LF is not necessary; CR+LF should be
enough. Newlines in a TEXTAREA which are not transmitted as '\r\n',
are in violation of RFC.
Bart, Thank you for confirming what I'd noticed in practice.
I do, however, have a few examples where single x'0A' characters have
found their way into my data files, and since this is the linend
sequence on my linux server, it caused problems.
I checked my code 'till I was blue in the face, and never found any way
this could happen unless a browser had submitted an x'0A' as a linend
from a TEXTAREA control. Of course, I have no control over what strange
browsers people might be using, so I took the pragmatic approach of
translating both x'0A' and x'0D' to my x'0102' "line-end" sequence.
There have been no re-occurrences of the problem.
I'm thinking of 4 possibilities:
- manual crafting of the URL (?data=one%0Atwo)
- an incorrect browser violating RFC
- an error in the regular expression or its execution order; in your
case it's necessary to first do:
'\r\n' -> '\x01\x02'
before
'\r' -> '\x01\x02' and '\n' -> '\x01\x02'
- incorrect URL parsing of the server script like ?data=one%250Atwo
or something with percent-encoding under UTF-8 (headache warning)
I would go for your pragmatic approach as well.
--
Bart
.
- Follow-Ups:
- Re: string length and newlines
- From: Michael White
- Re: string length and newlines
- References:
- string length and newlines
- From: Rob
- Re: string length and newlines
- From: David Mark
- Re: string length and newlines
- From: Bart Van der Donck
- Re: string length and newlines
- From: David Mark
- Re: string length and newlines
- From: Bart Van der Donck
- Re: string length and newlines
- From: David Mark
- Re: string length and newlines
- From: Steve Swift
- Re: string length and newlines
- From: Bart Van der Donck
- Re: string length and newlines
- From: Steve Swift
- string length and newlines
- Prev by Date: Re: Java Script problems
- Next by Date: Re: remove navigation bar
- Previous by thread: Re: string length and newlines
- Next by thread: Re: string length and newlines
- Index(es):
Relevant Pages
|