net-imap 0.2.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +2 -2
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +62 -0
- data/README.md +1 -2
- data/Rakefile +3 -0
- data/benchmarks/stringprep.yml +65 -0
- data/benchmarks/table-regexps.yml +39 -0
- data/docs/styles.css +36 -0
- data/lib/net/imap/authenticators/cram_md5.rb +5 -3
- data/lib/net/imap/authenticators/digest_md5.rb +11 -7
- data/lib/net/imap/authenticators/login.rb +4 -1
- data/lib/net/imap/authenticators/xoauth2.rb +20 -0
- data/lib/net/imap/authenticators.rb +41 -17
- data/lib/net/imap/command_data.rb +8 -11
- data/lib/net/imap/data_encoding.rb +101 -5
- data/lib/net/imap/errors.rb +1 -1
- data/lib/net/imap/flags.rb +105 -77
- data/lib/net/imap/response_data.rb +1077 -317
- data/lib/net/imap/response_parser.rb +66 -1
- data/lib/net/imap/sasl/saslprep.rb +55 -0
- data/lib/net/imap/sasl/saslprep_tables.rb +98 -0
- data/lib/net/imap/sasl/stringprep.rb +72 -0
- data/lib/net/imap/sasl/stringprep_tables.rb +153 -0
- data/lib/net/imap/sasl.rb +78 -0
- data/lib/net/imap.rb +1209 -283
- data/net-imap.gemspec +6 -4
- data/rakelib/rdoc.rake +70 -0
- data/rakelib/rfcs.rake +168 -0
- data/rakelib/saslprep.rake +30 -0
- data/rakelib/string_prep_tables_generator.rb +423 -0
- metadata +34 -4
data/net-imap.gemspec
CHANGED
@@ -10,8 +10,8 @@ end
|
|
10
10
|
Gem::Specification.new do |spec|
|
11
11
|
spec.name = name
|
12
12
|
spec.version = version
|
13
|
-
spec.authors = ["Shugo Maeda"]
|
14
|
-
spec.email = ["shugo@ruby-lang.org"]
|
13
|
+
spec.authors = ["Shugo Maeda", "nicholas a. evans"]
|
14
|
+
spec.email = ["shugo@ruby-lang.org", "nick@ekenosen.net"]
|
15
15
|
|
16
16
|
spec.summary = %q{Ruby client api for Internet Message Access Protocol}
|
17
17
|
spec.description = %q{Ruby client api for Internet Message Access Protocol}
|
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_dependency "net-protocol"
|
35
|
-
spec.add_dependency "
|
36
|
-
|
35
|
+
spec.add_dependency "date"
|
36
|
+
|
37
|
+
spec.add_development_dependency "digest"
|
38
|
+
spec.add_development_dependency "strscan"
|
37
39
|
end
|
data/rakelib/rdoc.rake
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# require "sdoc"
|
2
|
+
require "rdoc/task"
|
3
|
+
require_relative "../lib/net/imap"
|
4
|
+
require 'rdoc/rdoc' unless defined?(RDoc::Markup::ToHtml)
|
5
|
+
|
6
|
+
module RDoc::Generator
|
7
|
+
module NetIMAP
|
8
|
+
|
9
|
+
module RemoveRedundantParens
|
10
|
+
def param_seq
|
11
|
+
super.sub(/^\(\)\s*/, "")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ruby/rdoc/pull/936
|
16
|
+
module FixSectionComments
|
17
|
+
def markup(text)
|
18
|
+
@store ||= @parent&.store
|
19
|
+
super
|
20
|
+
end
|
21
|
+
def description; markup comment end
|
22
|
+
def comment; super || @comments&.first end
|
23
|
+
def parse(_comment_location = nil) super() end
|
24
|
+
end
|
25
|
+
|
26
|
+
# render "[label] data" lists as tables. adapted from "hanna-nouveau" gem.
|
27
|
+
module LabelListTable
|
28
|
+
def list_item_start(list_item, list_type)
|
29
|
+
case list_type
|
30
|
+
when :NOTE
|
31
|
+
%(<tr><td class='label'>#{Array(list_item.label).map{|label| to_html(label)}.join("<br />")}</td><td>)
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def list_end_for(list_type)
|
38
|
+
case list_type
|
39
|
+
when :NOTE then
|
40
|
+
"</td></tr>"
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class RDoc::AnyMethod
|
51
|
+
prepend RDoc::Generator::NetIMAP::RemoveRedundantParens
|
52
|
+
end
|
53
|
+
|
54
|
+
class RDoc::Context::Section
|
55
|
+
prepend RDoc::Generator::NetIMAP::FixSectionComments
|
56
|
+
end
|
57
|
+
|
58
|
+
class RDoc::Markup::ToHtml
|
59
|
+
LIST_TYPE_TO_HTML[:NOTE] = ['<table class="rdoc-list note-list"><tbody>', '</tbody></table>']
|
60
|
+
prepend RDoc::Generator::NetIMAP::LabelListTable
|
61
|
+
end
|
62
|
+
|
63
|
+
RDoc::Task.new do |doc|
|
64
|
+
doc.main = "README.md"
|
65
|
+
doc.title = "net-imap #{Net::IMAP::VERSION}"
|
66
|
+
doc.rdoc_dir = "doc"
|
67
|
+
doc.rdoc_files = FileList.new %w[lib/**/*.rb *.rdoc *.md]
|
68
|
+
doc.options << "--template-stylesheets" << "docs/styles.css"
|
69
|
+
# doc.generator = "hanna"
|
70
|
+
end
|
data/rakelib/rfcs.rake
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RFCS = {
|
4
|
+
|
5
|
+
# Historic IMAP RFCs
|
6
|
+
822 => "Internet Message Format (OBSOLETE)",
|
7
|
+
1730 => "IMAP4 (OBSOLETE)",
|
8
|
+
1731 => "IMAP4 Authentication Mechanisms (OBSOLETE)",
|
9
|
+
2060 => "IMAP4rev1 (OBSOLETE)",
|
10
|
+
2061 => "IMAP4 Compatibility with IMAP2bis",
|
11
|
+
2062 => "Internet Message Access Protocol - Obsolete Syntax",
|
12
|
+
2086 => "IMAP ACL (OBSOLETE)",
|
13
|
+
2087 => "IMAP QUOTA (OBSOLETE)",
|
14
|
+
2088 => "IMAP LITERAL+ (OBSOLETE)",
|
15
|
+
2095 => "IMAP/POP AUTHorize Extension for CRAM-MD5 (OBSOLETE)",
|
16
|
+
2192 => "IMAP URL Scheme (OBSOLETE)",
|
17
|
+
2222 => "SASL (OBSOLETE)",
|
18
|
+
2359 => "IMAP UIDPLUS (OBSOLETE)",
|
19
|
+
2822 => "Internet Message Format (OBSOLETE)",
|
20
|
+
3348 => "IMAP CHILDREN (OBSOLETED)",
|
21
|
+
4551 => "IMAP CONDSTORE (OBSOLETE)",
|
22
|
+
5162 => "IMAP QRESYNC (OBSOLETE)",
|
23
|
+
6237 => "IMAP MULTISEARCH (OBSOLETE)",
|
24
|
+
|
25
|
+
# Core IMAP RFCs
|
26
|
+
3501 => "IMAP4rev1", # supported by nearly all email servers
|
27
|
+
4466 => "Collected Extensions to IMAP4 ABNF",
|
28
|
+
9051 => "IMAP4rev2", # not widely supported yet
|
29
|
+
|
30
|
+
# RFC-9051 Normative References (not a complete list)
|
31
|
+
2152 => "UTF-7",
|
32
|
+
2180 => "IMAP4 Multi-Accessed Mailbox Practice",
|
33
|
+
2683 => "IMAP4 Implementation Recommendations",
|
34
|
+
3503 => "Message Disposition Notification (MDN) profile IMAP",
|
35
|
+
5234 => "ABNF",
|
36
|
+
5788 => "IMAP4 keyword registry",
|
37
|
+
|
38
|
+
# Internet Message format and envelope and body structure
|
39
|
+
5322 => "Internet Message Format (current)",
|
40
|
+
|
41
|
+
1864 => "[MD5]: The Content-MD5 Header Field",
|
42
|
+
2045 => "[MIME-IMB]: MIME Part One: Format of Internet Message Bodies",
|
43
|
+
2046 => "[MIME-IMT]: MIME Part Two: Media Types",
|
44
|
+
2047 => "[MIME-HDRS]: MIME Part Three: Header Extensions for Non-ASCII Text",
|
45
|
+
2183 => "[DISPOSITION]: The Content-Disposition Header",
|
46
|
+
2231 => "MIME Parameter Value and Encoded Word Extensions: " \
|
47
|
+
"Character Sets, Languages, and Continuations",
|
48
|
+
2557 => "[LOCATION]: MIME Encapsulation of Aggregate Documents",
|
49
|
+
2978 => "[CHARSET]: IANA Charset Registration Procedures, BCP 19",
|
50
|
+
3282 => "[LANGUAGE-TAGS]: Content Language Headers",
|
51
|
+
6532 => "[I18N-HDRS]: Internationalized Email Headers",
|
52
|
+
|
53
|
+
# SASL
|
54
|
+
4422 => "SASL, EXTERNAL",
|
55
|
+
|
56
|
+
# stringprep
|
57
|
+
3454 => "stringprep",
|
58
|
+
4013 => "SASLprep",
|
59
|
+
8265 => "PRECIS", # obsoletes SASLprep?
|
60
|
+
|
61
|
+
# SASL mechanisms (not a complete list)
|
62
|
+
2195 => "SASL CRAM-MD5",
|
63
|
+
4505 => "SASL ANONYMOUS",
|
64
|
+
4616 => "SASL PLAIN",
|
65
|
+
4752 => "SASL GSSAPI (Kerberos V5)",
|
66
|
+
5801 => "SASL GS2-*, GS2-KRB5",
|
67
|
+
5802 => "SASL SCRAM-*, SCRAM-SHA-1, SCRAM-SHA1-PLUS",
|
68
|
+
5803 => "LDAP Schema for Storing SCRAM Secrets",
|
69
|
+
6331 => "SASL DIGEST-MD5",
|
70
|
+
6595 => "SASL SAML20",
|
71
|
+
6616 => "SASL OPENID20",
|
72
|
+
7628 => "SASL OAUTH10A, OAUTHBEARER",
|
73
|
+
7677 => "SASL SCRAM-SHA-256, SCRAM-SHA256-PLUS",
|
74
|
+
|
75
|
+
# "Informational" RFCs
|
76
|
+
1733 => "Distributed E-Mail Models in IMAP4",
|
77
|
+
4549 => "Synchronization Operations for Disconnected IMAP4 Clients",
|
78
|
+
|
79
|
+
# TLS and other security concerns
|
80
|
+
2595 => "Using TLS with IMAP, POP3 and ACAP",
|
81
|
+
6151 => "Updated Security Considerations for MD5 Message-Digest and HMAC-MD5",
|
82
|
+
7525 => "Recommendations for Secure Use of TLS and DTLS",
|
83
|
+
7818 => "Updated TLS Server Identity Check Procedure for Email Protocols",
|
84
|
+
8314 => "Cleartext Considered Obsolete: Use of TLS for Email",
|
85
|
+
8996 => "Deprecating TLS 1.0 and TLS 1.1,",
|
86
|
+
|
87
|
+
# related email specifications
|
88
|
+
6376 => "DomainKeys Identified Mail (DKIM) Signatures",
|
89
|
+
6409 => "Message Submission for Mail",
|
90
|
+
|
91
|
+
# Other IMAP4 "Standards Track" RFCs
|
92
|
+
5092 => "IMAP URL Scheme",
|
93
|
+
5593 => "IMAP URL Access Identifier Extension",
|
94
|
+
5530 => "IMAP Response Codes",
|
95
|
+
6186 => "Use of SRV Records for Locating Email Submission/Access Services",
|
96
|
+
8305 => "Happy Eyeballs Version 2: Better Connectivity Using Concurrency",
|
97
|
+
|
98
|
+
# IMAP4 Extensions
|
99
|
+
2177 => "IMAP IDLE",
|
100
|
+
2193 => "IMAP MAILBOX-REFERRALS",
|
101
|
+
2221 => "IMAP LOGIN-REFERRALS",
|
102
|
+
2342 => "IMAP NAMESPACE",
|
103
|
+
2971 => "IMAP ID",
|
104
|
+
3502 => "IMAP MULTIAPPEND",
|
105
|
+
3516 => "IMAP BINARY",
|
106
|
+
3691 => "IMAP UNSELECT",
|
107
|
+
4314 => "IMAP ACL, RIGHTS=",
|
108
|
+
4315 => "IMAP UIDPLUS",
|
109
|
+
4467 => "IMAP URLAUTH",
|
110
|
+
4469 => "IMAP CATENATE",
|
111
|
+
4731 => "IMAP ESEARCH",
|
112
|
+
4959 => "IMAP SASL-IR",
|
113
|
+
4978 => "IMAP COMPRESS=DEFLATE",
|
114
|
+
5032 => "IMAP WITHIN",
|
115
|
+
5161 => "IMAP ENABLE",
|
116
|
+
5182 => "IMAP SEARCHRES",
|
117
|
+
5255 => "IMAP I18NLEVEL=1, I18NLEVEL=2, LANGUAGE",
|
118
|
+
5256 => "IMAP SORT, THREAD",
|
119
|
+
5257 => "IMAP ANNOTATE-EXPERIMENT-1",
|
120
|
+
5258 => "IMAP LIST-EXTENDED",
|
121
|
+
5259 => "IMAP CONVERT",
|
122
|
+
5267 => "IMAP CONTEXT=SEARCH, CONTEXT=SORT, ESORT",
|
123
|
+
5464 => "IMAP METADATA, METADATA-SERVER",
|
124
|
+
5465 => "IMAP NOTIFY",
|
125
|
+
5466 => "IMAP FILTERS",
|
126
|
+
5524 => "IMAP URLAUTH=BINARY", # see also: [RFC Errata 6214]
|
127
|
+
5550 => "IMAP URL-PARTIAL",
|
128
|
+
5738 => "IMAP UTF8=ALL, UTF8=APPEND, UTF8=USER", # OBSOLETED by RFC6855
|
129
|
+
5819 => "IMAP LIST-STATUS",
|
130
|
+
5957 => "IMAP SORT=DISPLAY",
|
131
|
+
6154 => "IMAP SPECIAL-USE, CREATE-SPECIAL-USE",
|
132
|
+
6203 => "IMAP SEARCH=FUZZY",
|
133
|
+
6785 => "IMAP IMAPSIEVE=",
|
134
|
+
6851 => "IMAP MOVE",
|
135
|
+
6855 => "IMAP UTF8=ACCEPT, UTF8=ONLY",
|
136
|
+
7162 => "IMAP CONDSTORE, QRESYNC",
|
137
|
+
7377 => "IMAP MULTISEARCH",
|
138
|
+
7888 => "IMAP LITERAL+, LITERAL-",
|
139
|
+
7889 => "IMAP APPENDLIMIT",
|
140
|
+
8437 => "IMAP UNAUTHENTICATE",
|
141
|
+
8438 => "IMAP STATUS=SIZE",
|
142
|
+
8440 => "IMAP LIST-MYRIGHTS",
|
143
|
+
8474 => "IMAP OBJECTID",
|
144
|
+
8508 => "IMAP REPLACE",
|
145
|
+
8514 => "IMAP SAVEDATE",
|
146
|
+
8970 => "IMAP PREVIEW",
|
147
|
+
9208 => "IMAP QUOTA, QUOTA=, QUOTASET",
|
148
|
+
|
149
|
+
# etc...
|
150
|
+
3629 => "UTF8",
|
151
|
+
6857 => "Post-Delivery Message Downgrading for I18n Email Messages",
|
152
|
+
|
153
|
+
}.freeze
|
154
|
+
|
155
|
+
task :rfcs => RFCS.keys.map {|n| "rfcs/rfc%04d.txt" % [n] }
|
156
|
+
|
157
|
+
RFC_RE = %r{rfcs/rfc(\d+).*\.txt}.freeze
|
158
|
+
rule RFC_RE do |t|
|
159
|
+
require "fileutils"
|
160
|
+
FileUtils.mkpath "rfcs"
|
161
|
+
require "net/http"
|
162
|
+
t.name =~ RFC_RE
|
163
|
+
rfc_url = URI("https://www.rfc-editor.org/rfc/rfc#$1.txt")
|
164
|
+
rfc_txt = Net::HTTP.get(rfc_url)
|
165
|
+
File.write(t.name, rfc_txt)
|
166
|
+
end
|
167
|
+
|
168
|
+
CLEAN.include "rfcs/rfc*.txt"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "string_prep_tables_generator"
|
4
|
+
|
5
|
+
generator = StringPrepTablesGenerator.new
|
6
|
+
|
7
|
+
file generator.json_filename => generator.json_deps do |t|
|
8
|
+
generator.generate_json_data_file
|
9
|
+
end
|
10
|
+
|
11
|
+
directory "lib/net/imap/sasl"
|
12
|
+
|
13
|
+
file "lib/net/imap/sasl/stringprep_tables.rb" => generator.rb_deps do |t|
|
14
|
+
File.write t.name, generator.stringprep_rb
|
15
|
+
end
|
16
|
+
|
17
|
+
file "lib/net/imap/sasl/saslprep_tables.rb" => generator.rb_deps do |t|
|
18
|
+
File.write t.name, generator.saslprep_rb
|
19
|
+
end
|
20
|
+
|
21
|
+
GENERATED_RUBY = FileList.new(
|
22
|
+
"lib/net/imap/sasl/stringprep_tables.rb",
|
23
|
+
"lib/net/imap/sasl/saslprep_tables.rb",
|
24
|
+
)
|
25
|
+
|
26
|
+
CLEAN.include generator.clean_deps
|
27
|
+
CLOBBER.include GENERATED_RUBY
|
28
|
+
|
29
|
+
task saslprep_rb: GENERATED_RUBY
|
30
|
+
task test: :saslprep_rb
|