Skip to content

Commit

Permalink
⚡️ Explicitly match RFC5530 and RFC9051 resp codes
Browse files Browse the repository at this point in the history
None of these response codes have any code data, so it isn't really
necessary to add explicit support.  This could have a (very small)
performance impact, by short-circuiting any further code data parsing
for matching codes.
  • Loading branch information
nevans committed Oct 28, 2023
1 parent 6a840b5 commit 1891124
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion lib/net/imap/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,35 @@ def resp_text
# capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1"
# *(SP capability)
#
# RFC5530:
# resp-text-code =/ "UNAVAILABLE" / "AUTHENTICATIONFAILED" /
# "AUTHORIZATIONFAILED" / "EXPIRED" /
# "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" /
# "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" /
# "SERVERBUG" / "CLIENTBUG" / "CANNOT" /
# "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" /
# "NONEXISTENT"
# RFC9051:
# resp-text-code = "ALERT" /
# "BADCHARSET" [SP "(" charset *(SP charset) ")" ] /
# capability-data / "PARSE" /
# "PERMANENTFLAGS" SP "(" [flag-perm *(SP flag-perm)] ")" /
# "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
# "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number /
# resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" /
# "UNAVAILABLE" / "AUTHENTICATIONFAILED" /
# "AUTHORIZATIONFAILED" / "EXPIRED" /
# "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" /
# "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" /
# "SERVERBUG" / "CLIENTBUG" / "CANNOT" /
# "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" /
# "NONEXISTENT" / "NOTSAVED" / "HASCHILDREN" /
# "CLOSED" /
# "UNKNOWN-CTE" /
# atom [SP 1*<any TEXT-CHAR except "]">]
# capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2"
# *(SP capability)
#
# RFC4315 (UIDPLUS), RFC9051 (IMAP4rev2):
# resp-code-apnd = "APPENDUID" SP nz-number SP append-uid
# resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set
Expand All @@ -1508,7 +1537,12 @@ def resp_text_code
when "APPENDUID" then SP!; resp_code_apnd__data # rev2, UIDPLUS
when "COPYUID" then SP!; resp_code_copy__data # rev2, UIDPLUS
when "BADCHARSET" then SP? ? charset__list : []
when "ALERT", "PARSE", "READ-ONLY", "READ-WRITE", "TRYCREATE"
when "ALERT", "PARSE", "READ-ONLY", "READ-WRITE", "TRYCREATE",
"UNAVAILABLE", "AUTHENTICATIONFAILED", "AUTHORIZATIONFAILED",
"EXPIRED", "PRIVACYREQUIRED", "CONTACTADMIN", "NOPERM", "INUSE",
"EXPUNGEISSUED", "CORRUPTION", "SERVERBUG", "CLIENTBUG", "CANNOT",
"LIMIT", "OVERQUOTA", "ALREADYEXISTS", "NONEXISTENT", "CLOSED",
"NOTSAVED", "UIDNOTSTICKY", "UNKNOWN-CTE", "HASCHILDREN"
when "NOMODSEQ" # CONDSTORE
else
SP? and text_chars_except_rbra
Expand Down

0 comments on commit 1891124

Please sign in to comment.