[smokeping-users] "Date" header in SmokeAlert mails may not be RFC compliant

Tobias Oetiker tobi at oetiker.ch
Fri May 27 14:37:07 CEST 2016


Hi Thorsten,

I guess forcing the locale to 'C' while generating the stamp
shold be fine ...

please create a PR on the smokeping github so that I can merge your
changes ...

https://github.com/oetiker/SmokePing


cheers
tobi


Today Thorsten Schöning wrote:

> Hi,
>
> we moved SmokeAlert recently to a new server and since then I
> recognized that the received mails are not properly sorted by my mail
> client. The reason is the following header, which is not RFC
> compliant:
>
> > Date: Fr, 27 Mai 2016 00:42:02 +0200
>
> "Mai" is the name of the month for the German locale, which we use on
> that server. My mail client interprets that as something around 26 Jan 2016
> 23:42:02, so both date and time are wrong.
>
> The problem is in Smokeping.pm around line 1931:
>
> > my $rfc2822stamp =  POSIX::strftime("%a, %e %b %Y %H:%M:%S %z", @stamp);
>
> At least using %a and %b is wrong here, since both are locale
> dependent[1], while RFC2822 is not[2]:
>
> > date-time       =       [ day-of-week "," ] date FWS time [CFWS]
> [...]
> > day-name        =       "Mon" / "Tue" / "Wed" / "Thu" /
> >                         "Fri" / "Sat" / "Sun"
> [...]
> > date            =       day month year
> [...]
> > month-name      =       "Jan" / "Feb" / "Mar" / "Apr" /
> >                         "May" / "Jun" / "Jul" / "Aug" /
> >                         "Sep" / "Oct" / "Nov" / "Dec"
>
> As you can see, "Fr" instead of "Fri" and "Mai" instead of "May" are
> both wrong. The same timestamp is given in the body, but this time
> only as a stringified localtime and in this case it seems to be locale
> independent:
>
> > my $stamp = localtime($time);
> > Fri May 27 00:42:02 2016
>
> Sadly, this timestamp is not RFC compliant as well. So in my opinion
> you should either create a truly locale independent date header using
> some other function or changing LC_* or such or remove it at all and
> let the mail system provide that. I do understand that you want to
> have both in sync, but in my opinion having the timestamp in the body
> is enough for most people and it simply avoids the problems I have
> currently.
>
> Thanks!
>
> [1]: http://man7.org/linux/man-pages/man3/strftime.3.html
> [2]: https://www.ietf.org/rfc/rfc2822.txt
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
www.oetiker.ch tobi at oetiker.ch +41 62 775 9902


More information about the smokeping-users mailing list