* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
@ 2006-09-11 13:11 ` Joel Aelwyn
2006-09-11 13:18 ` Mads Martin Joergensen
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Joel Aelwyn @ 2006-09-11 13:11 UTC (permalink / raw)
To: mlmmj
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
On Mon September 11 2006 06:35, Mads Martin Joergensen Mads Martin
Joergensen <mmj@mmj.dk> wrote:
> Hey together,
>
> Anyone object to this behaviour? Just heard on irc someone got bitten
> by this:
>
> --- chomp.c 20 Feb 2006 05:00:09 -0000 1.4
> +++ chomp.c 11 Sep 2006 12:34:28 -0000
> @@ -38,7 +38,7 @@
>
> i = strlen(str) - 1;
>
> - while(str[i] == '\n') {
> + while(str[i] == '\n' || str[i] == '\r') {
> str[i] = 0;
> i--;
> }
As far as I recall, getting anything with \r\n as an EOL pretty much
grossly violates the SMTP RFCs, so I'll make two suggestions about
this:
1) Limit it *strictly* to a single \r\n, not any random combination of
the two characters. You'll drastically reduce your chances of subtle
and nasty misbehaviours being introduced when (not if) some software
comes along and relies on things obeying the RFCs.
2) Make it a configurable option. Call it 'broken-CRLF-support' or
somesuch, because it most assuredly is.
Outlook is one of the primary offenders in this arena, for what it's
worth; DJB had -- probably has -- a rant up about it and why qmail
does/did not support a similar feature (it's been years since I used
qmail, but the combination of the two provided no end of headaches back
when I had to deal with them both at my workplace... and, to a one,
they were caused by Outlook blatantly violating the protocol
specifications.
--
Joel Aelwyn <joel@lightbearer.com>
[-- Attachment #2: Type: application/pgp-signature, Size: 191 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
2006-09-11 13:11 ` Joel Aelwyn
@ 2006-09-11 13:18 ` Mads Martin Joergensen
2006-09-11 13:25 ` Joel Aelwyn
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mads Martin Joergensen @ 2006-09-11 13:18 UTC (permalink / raw)
To: mlmmj
* Joel Aelwyn <joel@lightbearer.com> [Sep 11. 2006 15:12]:
> > Anyone object to this behaviour? Just heard on irc someone got bitten
> > by this:
> >
> > --- chomp.c 20 Feb 2006 05:00:09 -0000 1.4
> > +++ chomp.c 11 Sep 2006 12:34:28 -0000
> > @@ -38,7 +38,7 @@
> >
> > i = strlen(str) - 1;
> >
> > - while(str[i] = '\n') {
> > + while(str[i] = '\n' || str[i] = '\r') {
> > str[i] = 0;
> > i--;
> > }
>
> As far as I recall, getting anything with \r\n as an EOL pretty much
> grossly violates the SMTP RFCs, so I'll make two suggestions about
> this:
>
> 1) Limit it *strictly* to a single \r\n, not any random combination of
> the two characters. You'll drastically reduce your chances of subtle
> and nasty misbehaviours being introduced when (not if) some software
> comes along and relies on things obeying the RFCs.
>
> 2) Make it a configurable option. Call it 'broken-CRLF-support' or
> somesuch, because it most assuredly is.
>
> Outlook is one of the primary offenders in this arena, for what it's
> worth; DJB had -- probably has -- a rant up about it and why qmail
> does/did not support a similar feature (it's been years since I used
> qmail, but the combination of the two provided no end of headaches back
> when I had to deal with them both at my workplace... and, to a one,
> they were caused by Outlook blatantly violating the protocol
> specifications.
Ah, this has nothing to do with the smtp layer. SMTP always have to have
\r\n, and that's handled in send.
Problem is that when I for instance read a subscriber from a subscribers
file with the old behaviour and match
"mmj@mmj.dk" with "mmj@mmj.dk^M", they're different.
Same thing when reading control files.
--
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?"
-- A. P. J.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
2006-09-11 13:11 ` Joel Aelwyn
2006-09-11 13:18 ` Mads Martin Joergensen
@ 2006-09-11 13:25 ` Joel Aelwyn
2006-09-11 18:14 ` Morten K. Poulsen
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Joel Aelwyn @ 2006-09-11 13:25 UTC (permalink / raw)
To: mlmmj
[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]
On Mon September 11 2006 07:18, Mads Martin Joergensen Mads Martin
Joergensen <mmj@mmj.dk> wrote:
> * Joel Aelwyn <joel@lightbearer.com> [Sep 11. 2006 15:12]:
> > > Anyone object to this behaviour? Just heard on irc someone got
> > > bitten by this:
> > >
> > > --- chomp.c 20 Feb 2006 05:00:09 -0000 1.4
> > > +++ chomp.c 11 Sep 2006 12:34:28 -0000
> > > @@ -38,7 +38,7 @@
> > >
> > > i = strlen(str) - 1;
> > >
> > > - while(str[i] == '\n') {
> > > + while(str[i] == '\n' || str[i] == '\r') {
> > > str[i] = 0;
> > > i--;
> > > }
> >
> > As far as I recall, getting anything with \r\n as an EOL pretty
> > much grossly violates the SMTP RFCs, so I'll make two suggestions
> > about this:
> >
> > 1) Limit it *strictly* to a single \r\n, not any random combination
> > of the two characters. You'll drastically reduce your chances of
> > subtle and nasty misbehaviours being introduced when (not if) some
> > software comes along and relies on things obeying the RFCs.
> >
> > 2) Make it a configurable option. Call it 'broken-CRLF-support' or
> > somesuch, because it most assuredly is.
> >
> > Outlook is one of the primary offenders in this arena, for what
> > it's worth; DJB had -- probably has -- a rant up about it and why
> > qmail does/did not support a similar feature (it's been years since
> > I used qmail, but the combination of the two provided no end of
> > headaches back when I had to deal with them both at my workplace...
> > and, to a one, they were caused by Outlook blatantly violating the
> > protocol specifications.
>
> Ah, this has nothing to do with the smtp layer. SMTP always have to
> have \r\n, and that's handled in send.
>
> Problem is that when I for instance read a subscriber from a
> subscribers file with the old behaviour and match
>
> "mmj@mmj.dk" with "mmj@mmj.dk^M", they're different.
>
> Same thing when reading control files.
Ah, ick. But, in that case, being fancy is probably not warranted...
anyone who would get bitten by the broader behaviour is already doing
something they need to be smacked for. Comments withdrawn, or at least
deferred into the 'nice idea, maybe, but then again maybe not'
bucket. :)
--
Joel Aelwyn <joel@lightbearer.com>
[-- Attachment #2: Type: application/pgp-signature, Size: 191 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
` (2 preceding siblings ...)
2006-09-11 13:25 ` Joel Aelwyn
@ 2006-09-11 18:14 ` Morten K. Poulsen
2006-09-11 23:25 ` Mads Martin Joergensen
2006-09-12 15:50 ` Morten K. Poulsen
5 siblings, 0 replies; 7+ messages in thread
From: Morten K. Poulsen @ 2006-09-11 18:14 UTC (permalink / raw)
To: mlmmj
On Mon, 11 Sep 2006 14:35:59 +0200, Mads Martin Joergensen <mmj@mmj.dk> wrote:
> Anyone object to this behaviour?
[snip]
> - while(str[i] = '\n') {
> + while(str[i] = '\n' || str[i] = '\r') {
Fine by me.
Was the guy using the twisted BSD variant from Apple Computer, which uses \r and not \n?
Morten
--
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
` (3 preceding siblings ...)
2006-09-11 18:14 ` Morten K. Poulsen
@ 2006-09-11 23:25 ` Mads Martin Joergensen
2006-09-12 15:50 ` Morten K. Poulsen
5 siblings, 0 replies; 7+ messages in thread
From: Mads Martin Joergensen @ 2006-09-11 23:25 UTC (permalink / raw)
To: mlmmj
* Morten K. Poulsen <morten@afdelingp.dk> [Sep 11. 2006 20:14]:
>
> On Mon, 11 Sep 2006 14:35:59 +0200, Mads Martin Joergensen <mmj@mmj.dk> wrote:
> > Anyone object to this behaviour?
> [snip]
> > - while(str[i] = '\n') {
> > + while(str[i] = '\n' || str[i] = '\r') {
>
> Fine by me.
>
> Was the guy using the twisted BSD variant from Apple Computer, which uses \r and not \n?
No, his sysadmins based on windows added ^M's. BSD wouldn't even think
of such--albeit Apply have touched it :)
--
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?"
-- A. P. J.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] chomp to remove '\r' as well
2006-09-11 12:35 [PATCH] chomp to remove '\r' as well Mads Martin Joergensen
` (4 preceding siblings ...)
2006-09-11 23:25 ` Mads Martin Joergensen
@ 2006-09-12 15:50 ` Morten K. Poulsen
5 siblings, 0 replies; 7+ messages in thread
From: Morten K. Poulsen @ 2006-09-12 15:50 UTC (permalink / raw)
To: mlmmj
Mads Martin Joergensen <mmj@mmj.dk> wrote:
> * Morten K. Poulsen <morten@afdelingp.dk> [Sep 11. 2006 20:14]:
>> Was the guy using the twisted BSD variant from Apple Computer, which
>> uses \r and not \n?
>
> No, his sysadmins based on windows added ^M's. BSD wouldn't even think
> of such--albeit Apply have touched it :)
Hehe, I see. I thought the Macintoshes still used only \r, but they stopped doing that in Mac OS X. Probably a wise decision :)
Morten
--
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/
^ permalink raw reply [flat|nested] 7+ messages in thread