Re: interpretation of whitespace inside obs-phrase
Timo Sirainen <[email protected]> Sat, 25 Aug 2012 11:17:12 +0300
| Newsgroups | gmane.ietf.rfc822 |
|---|---|
| Message-ID | <[email protected]> |
On 25.8.2012, at 8.25, Jay Freeman (saurik) wrote: > Hello. I am working on an implementation of an e-mail parsing library, and thereby am getting intimate with RFC5322. I'm not as much of an expert in this as I'm sure others in this list are, but here's my thoughts on it: > display-name = phrase > phrase = 1*word / obs-phrase > obs-phrase = word *(word / "." / CFWS) > word = atom / quoted-string > atom = [CFWS] 1*atext [CFWS] > quoted-string = [CFWS] > DQUOTE *([FWS] qcontent) [FWS] DQUOTE > [CFWS] There is no dot-atom above. > Both atom and dot-atom are interpreted as a single unit, comprising > the string of characters that make it up. Semantically, the optional > comments and FWS surrounding the rest of the characters are not part > of the atom; the atom is only the run of atext characters in an atom, > or the atext and "." characters in a dot-atom. So the "dot-atom" mentioned here doesn't apply. > Semantically, neither the optional CFWS outside of the quote > characters nor the quote characters themselves are part of the > quoted-string; the quoted-string is what is contained between the two > quote characters. As stated earlier, the "\" in any quoted-pair and > the CRLF in any FWS/CFWS that appears within the quoted-string are > semantically "invisible" and therefore not part of the quoted-string > either. Both of these basically say that the whitespace outside atoms/quoted-strings doesn't matter for that specific atom/quoted-string. > In these cases, I would then presume, I would end up with the display names |JayFreeman| and |JayR.Freeman|. But they don't say that whitespace doesn't matter for the entire phrase, only its individual parts. I'm not sure if anything specifically requires you to show the whitespace in any specific way though, so my parser attempts to use a single space character where there originally was whitespace. The way I handle obs-phrase is to try to parse either quoted-string or "atom-or-dot" and then append a space. The "atom-or-dot" is my own thing, which parses atom chars or dot chars until it reaches something else. So the end result is that you get: 1:|Jay Freeman| 2:|Jay R. Freeman| 3:|Jay R Freeman| And also |Jay.R.Freeman| also produces |Jay.R.Freeman| (I think many parsers will add whitespace after dots there). _______________________________________________ ietf-822 mailing list [email protected] https://www.ietf.org/mailman/listinfo/ietf-822