mail 2.7.0 → 2.7.1.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0f77ef2d4e2ecc02b59f5431cd56e3c0a5569262
4
- data.tar.gz: a6e4a0ee6b7d2d1a824578a43a5c73893ae3fa10
2
+ SHA256:
3
+ metadata.gz: c7a286430676f89847640cf02f8b5a0e1e7c1e4151a629f0d26f8bb660bc48e5
4
+ data.tar.gz: 5d8aa0bcf4b95a7d01baea338edb3133c3ff47924e627b8d0a424e93a6d7fe7c
5
5
  SHA512:
6
- metadata.gz: 70f3d73bb71de6e3d6121df0e93cd3909fb35eef6716c0597803a67ee341445385951dc662901dce2e806840c399d1f6ea0015987b2944b9fb24f9973a8e97af
7
- data.tar.gz: 0d7283e6e57f4600704b9d9e45ae17e77e8105db42a394174217c7f488e81ac4598fef6492e85e24a8e763ceb302ee3ee6754fa1bf3bf9777bfa37a707157d4b
6
+ metadata.gz: a816d0c0cb167ece62be9a2749527668c70cd898d0c576d136ad6be89c1bfa3d93f109d1438d1f6e8b54caabfea58aee08aab3f6f5aaf32cbd7a6716b4b8db7d
7
+ data.tar.gz: 753249413f3a2bd8cf5a9666e1b1e39e3ffe7599b305302ab0e0ad4d323d6854e5c081cb154f2ac96c2b3fa1cb4ba1d413d81dfe49b290a5e059727ccab5f3f4
@@ -39,9 +39,9 @@ module Mail
39
39
  else
40
40
  # Do join first incase we have been given an Array in Ruby 1.9
41
41
  if string.respond_to?(:join)
42
- @raw_source = string.join('')
42
+ @raw_source = ::Mail::Utilities.to_crlf(string.join(''))
43
43
  elsif string.respond_to?(:to_s)
44
- @raw_source = string.to_s
44
+ @raw_source = ::Mail::Utilities.to_crlf(string.to_s)
45
45
  else
46
46
  raise "You can only assign a string or an object that responds_to? :join or :to_s to a body."
47
47
  end
@@ -16,7 +16,7 @@ module Mail
16
16
  control = control.dup.force_encoding(Encoding::BINARY)
17
17
  end
18
18
 
19
- CRLF = /\r\n/
19
+ CRLF = /\r?\n/
20
20
  WSP = /[#{white_space}]/
21
21
  FWS = /#{CRLF}#{WSP}*/
22
22
  TEXT = /[#{text}]/ # + obs-text
@@ -33,7 +33,7 @@ module Mail
33
33
  end
34
34
 
35
35
  def self.negotiate(message_encoding, source_encoding, str, allowed_encodings = nil)
36
- message_encoding = Encodings.get_encoding(message_encoding || '8bit')
36
+ message_encoding = Encodings.get_encoding(message_encoding) || Encodings.get_encoding('8bit')
37
37
  source_encoding = Encodings.get_encoding(source_encoding)
38
38
 
39
39
  if message_encoding && source_encoding && message_encoding.can_transport?(source_encoding) && source_encoding.compatible_input?(str)
@@ -147,6 +147,8 @@ module Mail
147
147
  end
148
148
  end
149
149
 
150
+ attr_reader :unparsed_value
151
+
150
152
  # Create a field by name and optional value:
151
153
  #
152
154
  # Mail::Field.new("field-name", "value")
@@ -291,7 +293,7 @@ module Mail
291
293
  # treated in its unfolded form for further syntactic and semantic
292
294
  # evaluation.
293
295
  def unfold(string)
294
- string.gsub(/#{CRLF}(#{WSP})/m, '\1')
296
+ string.gsub(/#{Constants::CRLF}(#{Constants::WSP})/m, '\1')
295
297
  end
296
298
  end
297
299
  end
@@ -175,7 +175,7 @@ module Mail
175
175
  # and: audio/x-midi;\r\n\sname=Part .exe
176
176
  params = $2.to_s.split(/\s+/)
177
177
  params = params.map { |i| i.to_s.chomp.strip }
178
- params = params.map { |i| i.split(/\s*\=\s*/) }
178
+ params = params.map { |i| i.split(/\s*\=\s*/, 2) }
179
179
  params = params.map { |i| "#{i[0]}=#{dquote(i[1].to_s.gsub(/;$/,""))}" }.join('; ')
180
180
  "#{type}; #{params}"
181
181
  when val =~ /^\s*$/
@@ -1984,7 +1984,7 @@ module Mail
1984
1984
 
1985
1985
  private
1986
1986
 
1987
- HEADER_SEPARATOR = /#{CRLF}#{CRLF}/
1987
+ HEADER_SEPARATOR = /#{Constants::CRLF}#{Constants::CRLF}/
1988
1988
 
1989
1989
  # 2.1. General Description
1990
1990
  # A message consists of header fields (collectively called "the header
@@ -2000,8 +2000,7 @@ module Mail
2000
2000
  end
2001
2001
 
2002
2002
  def raw_source=(value)
2003
- value = value.dup.force_encoding(Encoding::BINARY) if RUBY_VERSION >= "1.9.1"
2004
- @raw_source = ::Mail::Utilities.to_crlf(value)
2003
+ @raw_source = value
2005
2004
  end
2006
2005
 
2007
2006
  # see comments to body=. We take data and process it lazily
@@ -2030,7 +2029,7 @@ module Mail
2030
2029
 
2031
2030
  def set_envelope_header
2032
2031
  raw_string = raw_source.to_s
2033
- if match_data = raw_string.match(/\AFrom\s(#{TEXT}+)#{CRLF}/m)
2032
+ if match_data = raw_string.match(/\AFrom\s(#{TEXT}+)#{Constants::CRLF}/m)
2034
2033
  set_envelope(match_data[1])
2035
2034
  self.raw_source = raw_string.sub(match_data[0], "")
2036
2035
  end
@@ -104,8 +104,8 @@ module Mail
104
104
 
105
105
  # A part may not have a header.... so, just init a body if no header
106
106
  def parse_message
107
- header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
108
- if header_part =~ HEADER_LINE
107
+ header_part, body_part = raw_source.split(/#{Constants::CRLF}#{Constants::WSP}*#{Constants::CRLF}/m, 2)
108
+ if header_part =~ Constants::HEADER_LINE
109
109
  self.header = header_part
110
110
  self.body = body_part
111
111
  else
@@ -24,9 +24,9 @@ module Mail
24
24
  # If the string supplied has PHRASE unsafe characters in it, will return the string quoted
25
25
  # in double quotes, otherwise returns the string unmodified
26
26
  def quote_phrase( str )
27
- if RUBY_VERSION >= '1.9'
27
+ if str.respond_to?(:force_encoding)
28
28
  original_encoding = str.encoding
29
- ascii_str = str.dup.force_encoding('ASCII-8BIT')
29
+ ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
30
30
  if (PHRASE_UNSAFE === ascii_str)
31
31
  dquote(ascii_str).force_encoding(original_encoding)
32
32
  else
@@ -45,7 +45,17 @@ module Mail
45
45
  # If the string supplied has TOKEN unsafe characters in it, will return the string quoted
46
46
  # in double quotes, otherwise returns the string unmodified
47
47
  def quote_token( str )
48
- token_safe?( str ) ? str : dquote(str)
48
+ if str.respond_to?(:force_encoding)
49
+ original_encoding = str.encoding
50
+ ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
51
+ if token_safe?( ascii_str )
52
+ str
53
+ else
54
+ dquote(ascii_str).force_encoding(original_encoding)
55
+ end
56
+ else
57
+ token_safe?( str ) ? str : dquote(str)
58
+ end
49
59
  end
50
60
 
51
61
  # Wraps supplied string in double quotes and applies \-escaping as necessary,
@@ -241,45 +251,35 @@ module Mail
241
251
 
242
252
  end
243
253
 
244
- # Test String#encode works correctly with line endings.
245
- # Some versions of Ruby (e.g. MRI <1.9, JRuby, Rubinius) line ending
246
- # normalization does not work correctly or did not have #encode.
247
- if ("\r".encode(:universal_newline => true) rescue nil) == LF &&
248
- (LF.encode(:crlf_newline => true) rescue nil) == CRLF
249
- # Using String#encode is better performing than Regexp
254
+ def self.binary_unsafe_to_lf(string) #:nodoc:
255
+ string.gsub(/\r\n|\r/, LF)
256
+ end
250
257
 
251
- def self.binary_unsafe_to_lf(string) #:nodoc:
252
- string.encode(string.encoding, :universal_newline => true)
258
+ TO_CRLF_REGEX =
259
+ if RUBY_VERSION >= '1.9'
260
+ # This 1.9 only regex can save a reasonable amount of time (~20%)
261
+ # by not matching "\r\n" so the string is returned unchanged in
262
+ # the common case.
263
+ Regexp.new("(?<!\r)\n|\r(?!\n)")
264
+ else
265
+ /\n|\r\n|\r/
253
266
  end
254
267
 
255
- def self.binary_unsafe_to_crlf(string) #:nodoc:
256
- string.encode(string.encoding, :universal_newline => true).encode!(string.encoding, :crlf_newline => true)
257
- end
268
+ def self.binary_unsafe_to_crlf(string) #:nodoc:
269
+ string.gsub(TO_CRLF_REGEX, CRLF)
270
+ end
258
271
 
272
+ if RUBY_VERSION < '1.9'
259
273
  def self.safe_for_line_ending_conversion?(string) #:nodoc:
260
274
  string.ascii_only?
261
275
  end
262
276
  else
263
- def self.binary_unsafe_to_lf(string) #:nodoc:
264
- string.gsub(/\r\n|\r/, LF)
265
- end
266
-
267
- TO_CRLF_REGEX =
268
- if RUBY_VERSION >= '1.9'
269
- # This 1.9 only regex can save a reasonable amount of time (~20%)
270
- # by not matching "\r\n" so the string is returned unchanged in
271
- # the common case.
272
- Regexp.new("(?<!\r)\n|\r(?!\n)")
277
+ def self.safe_for_line_ending_conversion?(string) #:nodoc:
278
+ if string.encoding == Encoding::BINARY
279
+ string.ascii_only?
273
280
  else
274
- /\n|\r\n|\r/
281
+ string.valid_encoding?
275
282
  end
276
-
277
- def self.binary_unsafe_to_crlf(string) #:nodoc:
278
- string.gsub(TO_CRLF_REGEX, CRLF)
279
- end
280
-
281
- def self.safe_for_line_ending_conversion?(string) #:nodoc:
282
- string.ascii_only?
283
283
  end
284
284
  end
285
285
 
@@ -4,8 +4,8 @@ module Mail
4
4
 
5
5
  MAJOR = 2
6
6
  MINOR = 7
7
- PATCH = 0
8
- BUILD = nil
7
+ PATCH = 1
8
+ BUILD = 'rc1'
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikel Lindsaar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_mime
@@ -241,12 +241,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
- - - ">="
244
+ - - ">"
245
245
  - !ruby/object:Gem::Version
246
- version: '0'
246
+ version: 1.3.1
247
247
  requirements: []
248
248
  rubyforge_project:
249
- rubygems_version: 2.6.11
249
+ rubygems_version: 2.7.3
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: Mail provides a nice Ruby DSL for making, sending and reading emails.