Skip to content

Commit

Permalink
✨ Add support for GMail's X-GM-EXT-1 extension [🚧 WIP: tests, docs]
Browse files Browse the repository at this point in the history
Adds support for fetching `X-GM-MSGID`, `X-GM-THRID`, and `X-GM-LABELS`
on GMail servers.  Note that the `X-GM-RAW` search attribute does not
need any special support.

See specs at https://developers.google.com/gmail/imap/imap-extensions.
  • Loading branch information
nevans committed Nov 10, 2023
1 parent 3410e14 commit 7292f1b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/net/imap/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ def case_insensitive__nstring
# ; Strictly ascending
alias uniqueid nz_number

# valid number ranges are not enforced by parser
#
# a 64-bit unsigned integer and is the decimal equivalent for the ID hex
# string used in the web interface and the Gmail API.
alias x_gm_id number

# [RFC3501 & RFC9051:]
# response = *(continue-req / response-data) response-done
#
Expand Down Expand Up @@ -765,6 +771,9 @@ def msg_att(n)
when "RFC822.HEADER" then nstring # not in rev2
when "RFC822.TEXT" then nstring # not in rev2
when "MODSEQ" then parens__modseq # CONDSTORE
when "X-GM-MSGID" then x_gm_id # GMail TODO:tests
when "X-GM-THRID" then x_gm_id # GMail TODO:tests
when "X-GM-LABELS" then x_gm_labels # GMail TODO:tests
else parse_error("unknown attribute `%s' for {%d}", name, n)
end
attr[name] = val
Expand Down Expand Up @@ -1765,6 +1774,16 @@ def parens__mbx_list_flags
.split(nil).map! { _1.capitalize.to_sym }
end

def x_gm_label; accept(T_BSLASH) ? atom.capitalize.to_sym : astring end

def x_gm_labels
lpar; return [] if rpar?
labels << x_gm_label
labels << x_gm_label while SP?
rpar
labels
end

# See https://www.rfc-editor.org/errata/rfc3501
#
# charset = atom / quoted
Expand Down

0 comments on commit 7292f1b

Please sign in to comment.