ietf-smtp
[Top] [All Lists]

Received,mailbox-list,address-list parsing.

2008-12-18 07:05:44

Hi,

After bigger reading and coding, some questions arise.

Like:

/// RFC 5321 4.4.
   ///     Time-stamp-line = "Received:" FWS Stamp CRLF
/// /// Stamp = From-domain By-domain Opt-info [CFWS] ";" FWS date-time /// ; where "date-time" is as defined in RFC 5322 [4]
   ///                     ; but the "obs-" forms, especially two-digit
/// ; years, are prohibited in SMTP and MUST NOT be used. /// /// From-domain = "FROM" FWS Extended-Domain
   ///
   ///     By-domain       = CFWS "BY" FWS Extended-Domain
   ///
/// Extended-Domain = Domain / ( Domain FWS "(" TCP-info ")" ) / ( address-literal FWS "(" TCP-info ")" )
   ///
/// TCP-info = address-literal / ( Domain FWS address-literal ) /// ; Information derived by server from TCP connection not client EHLO.
   ///
/// Opt-info = [Via] [With] [ID] [For] [Additional-Registered-Clauses]
   ///
   ///     Via             = CFWS "VIA" FWS Link
   ///
   ///     With            = CFWS "WITH" FWS Protocol
   ///
   ///     ID              = CFWS "ID" FWS ( Atom / msg-id )
   ///                     ; msg-id is defined in RFC 5322 [4]
   ///
   ///     For            = CFWS "FOR" FWS ( Path / Mailbox )

Here for can be path / or mailbox, detecting if value is apth or angle-addr isn't problem. But if
value is mailbox.

///         mailbox    = name-addr / addr-spec
   ///     name-addr  = [display-name] angle-addr
   ///     angle-addr = [CFWS] "<" addr-spec ">" [CFWS]

mailbox syntax allows: 3 value combinations.
1) john(_dot_)doe(_at_)domain(_dot_)com
2) <john(_dot_)doe(_at_)domain(_dot_)com>
3) john <john(_dot_)doe(_at_)domain(_dot_)com>
--
Is that allowed(without quotes): 4) john doe 
<john(_dot_)doe(_at_)domain(_dot_)com>

If i get right, the only way to parse received value is block by block from left to right. So how to distinguish what address type it is ? Is the only way to read ahead and then to guess whats it is ?

Similar case is with address-list, it may contain mailbox or group addresses, so who to distinguish address here ?

   ///     address-list = (address *("," address))
   ///     address      = mailbox / group

String split can't be used to split addresses and then process each as block, so addresses must be read continuously. Or i miss some thing.

I'm trying to find bullet-proof way to parse this values.

Any comments are welcome.

Thanks,

<Prev in Thread] Current Thread [Next in Thread>