Skip to content

Commit 9ae5627

Browse files
committed
📝 collected RFC ABNF for most fetch msg-att
1 parent 8106847 commit 9ae5627

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

lib/net/imap/response_parser.rb

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,53 @@ def response_data__simple_numeric
607607
alias mailbox_data__exists response_data__simple_numeric
608608
alias mailbox_data__recent response_data__simple_numeric
609609

610+
# RFC3501 & RFC9051:
611+
# msg-att = "(" (msg-att-dynamic / msg-att-static)
612+
# *(SP (msg-att-dynamic / msg-att-static)) ")"
613+
#
614+
# msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")"
615+
# RFC5257 (ANNOTATE extension):
616+
# msg-att-dynamic =/ "ANNOTATION" SP
617+
# ( "(" entry-att *(SP entry-att) ")" /
618+
# "(" entry *(SP entry) ")" )
619+
# RFC7162 (CONDSTORE extension):
620+
# msg-att-dynamic =/ fetch-mod-resp
621+
# fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")"
622+
# RFC8970 (PREVIEW extension):
623+
# msg-att-dynamic =/ "PREVIEW" SP nstring
624+
#
625+
# RFC3501:
626+
# msg-att-static = "ENVELOPE" SP envelope /
627+
# "INTERNALDATE" SP date-time /
628+
# "RFC822" [".HEADER" / ".TEXT"] SP nstring /
629+
# "RFC822.SIZE" SP number /
630+
# "BODY" ["STRUCTURE"] SP body /
631+
# "BODY" section ["<" number ">"] SP nstring /
632+
# "UID" SP uniqueid
633+
# RFC3516 (BINARY extension):
634+
# msg-att-static =/ "BINARY" section-binary SP (nstring / literal8)
635+
# / "BINARY.SIZE" section-binary SP number
636+
# RFC8514 (SAVEDATE extension):
637+
# msg-att-static =/ "SAVEDATE" SP (date-time / nil)
638+
# RFC8474 (OBJECTID extension):
639+
# msg-att-static =/ fetch-emailid-resp / fetch-threadid-resp
640+
# fetch-emailid-resp = "EMAILID" SP "(" objectid ")"
641+
# fetch-threadid-resp = "THREADID" SP ( "(" objectid ")" / nil )
642+
# RFC9051:
643+
# msg-att-static = "ENVELOPE" SP envelope /
644+
# "INTERNALDATE" SP date-time /
645+
# "RFC822.SIZE" SP number64 /
646+
# "BODY" ["STRUCTURE"] SP body /
647+
# "BODY" section ["<" number ">"] SP nstring /
648+
# "BINARY" section-binary SP (nstring / literal8) /
649+
# "BINARY.SIZE" section-binary SP number /
650+
# "UID" SP uniqueid
651+
#
652+
# Re https://www.rfc-editor.org/errata/eid7246, I'm adding "offset" to the
653+
# official "BINARY" ABNF, like so:
654+
#
655+
# msg-att-static =/ "BINARY" section-binary ["<" number ">"] SP
656+
# (nstring / literal8)
610657
def msg_att(n)
611658
match(T_LPAR)
612659
attr = {}
@@ -996,6 +1043,23 @@ def body_extension
9961043
end
9971044
end
9981045

1046+
# section = "[" [section-spec] "]"
1047+
#
1048+
# section-spec = section-msgtext / (section-part ["." section-text])
1049+
# section-msgtext = "HEADER" /
1050+
# "HEADER.FIELDS" [".NOT"] SP header-list /
1051+
# "TEXT"
1052+
# ; top-level or MESSAGE/RFC822 or
1053+
# ; MESSAGE/GLOBAL part
1054+
# section-part = nz-number *("." nz-number)
1055+
# ; body part reference.
1056+
# ; Allows for accessing nested body parts.
1057+
# section-text = section-msgtext / "MIME"
1058+
# ; text other than actual body part (headers,
1059+
# ; etc.)
1060+
#
1061+
# header-list = "(" header-fld-name *(SP header-fld-name) ")"
1062+
#
9991063
def section
10001064
str = String.new
10011065
token = match(T_LBRA)
@@ -1031,6 +1095,14 @@ def section
10311095
return str
10321096
end
10331097

1098+
# header-fld-name = astring
1099+
#
1100+
# RFC5233:
1101+
# optional-field = field-name ":" unstructured CRLF
1102+
# field-name = 1*ftext
1103+
# ftext = %d33-57 / ; Printable US-ASCII
1104+
# %d59-126 ; characters not including
1105+
# ; ":".
10341106
def format_string(str)
10351107
case str
10361108
when ""

0 commit comments

Comments
 (0)