net-smtp 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/net/smtp.rb +18 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 642b3ab1e326ac890c33653e8293421558c50a8d6cdc3483b5c41edb26bdaebe
4
- data.tar.gz: 8c31ba69f42e11a41eda04a31cffe375bcca4cee447b9bc1b1cda218a8f905f3
3
+ metadata.gz: 314f553cc9e988f56b964e62836e95e323974b6a66c26e2f02d1e6a7cc08e886
4
+ data.tar.gz: 43a203a0622f49e2fb32a6c8bc0f644cb703e3bc3bc1f25aa114434c1a9cc8e5
5
5
  SHA512:
6
- metadata.gz: a2b5433005fe906635edee7e0bb1c9d0d81a6fff1da5af97ad39b16bf7e8a3330dafa9d9a513a3e83b17fe5a53c1489e07f52445c8cdefd81192f83a8cc4f6e7
7
- data.tar.gz: be1a223db50575fbb0f14ebac46af142b0f109d422049d5ae49c57a0548c4560904931d8b8c75cc35e95c1978ad9c620ed059bee541d7b443f7a3668e1df2a43
6
+ metadata.gz: 486381bf1eee2cbd7cb4f12ca0253ee5b06fc2b1a012b3786bda9b30456c338c5de40889e639275cfcf22a83064d7c468aa06c8e21438adb1d1ab2133a3933eb
7
+ data.tar.gz: 97659f9e6505ea3aa10db92d5a99dc39d01ca55468ca28934b77061ccedd7ce74d8652927304ddf7fe4a21622e3572cca3bb92f19bae3a1b004bc7909783b530
data/lib/net/smtp.rb CHANGED
@@ -18,11 +18,13 @@
18
18
  #
19
19
 
20
20
  require 'net/protocol'
21
- require 'digest/md5'
22
- require 'timeout'
23
21
  begin
24
22
  require 'openssl'
25
23
  rescue LoadError
24
+ begin
25
+ require 'digest/md5'
26
+ rescue LoadError
27
+ end
26
28
  end
27
29
 
28
30
  module Net
@@ -184,7 +186,7 @@ module Net
184
186
  # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
185
187
  #
186
188
  class SMTP < Protocol
187
- VERSION = "0.3.2"
189
+ VERSION = "0.3.3"
188
190
 
189
191
  Revision = %q$Revision$.split[1]
190
192
 
@@ -626,6 +628,16 @@ module Net
626
628
 
627
629
  private
628
630
 
631
+ def digest_class
632
+ @digest_class ||= if defined?(OpenSSL::Digest)
633
+ OpenSSL::Digest
634
+ elsif defined?(::Digest)
635
+ ::Digest
636
+ else
637
+ raise '"openssl" or "digest" library is required'
638
+ end
639
+ end
640
+
629
641
  def tcp_socket(address, port)
630
642
  begin
631
643
  Socket.tcp address, port, nil, nil, connect_timeout: @open_timeout
@@ -888,14 +900,14 @@ module Net
888
900
 
889
901
  # CRAM-MD5: [RFC2195]
890
902
  def cram_md5_response(secret, challenge)
891
- tmp = Digest::MD5.digest(cram_secret(secret, IMASK) + challenge)
892
- Digest::MD5.hexdigest(cram_secret(secret, OMASK) + tmp)
903
+ tmp = digest_class::MD5.digest(cram_secret(secret, IMASK) + challenge)
904
+ digest_class::MD5.hexdigest(cram_secret(secret, OMASK) + tmp)
893
905
  end
894
906
 
895
907
  CRAM_BUFSIZE = 64
896
908
 
897
909
  def cram_secret(secret, mask)
898
- secret = Digest::MD5.digest(secret) if secret.size > CRAM_BUFSIZE
910
+ secret = digest_class::MD5.digest(secret) if secret.size > CRAM_BUFSIZE
899
911
  buf = secret.ljust(CRAM_BUFSIZE, "\0")
900
912
  0.upto(buf.size - 1) do |i|
901
913
  buf[i] = (buf[i].ord ^ mask).chr
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-smtp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-28 00:00:00.000000000 Z
11
+ date: 2022-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol