mail_address 1.2.15 → 1.2.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 178331c0a94b43c78dae091e6072d33399aea7d6
4
- data.tar.gz: 88a14c0c1c218dac32e973350e36f7fbf7b02c47
3
+ metadata.gz: 9444cdca2ba62456c8945411801b4dca251a7d44
4
+ data.tar.gz: a939e18eaab3b80c2a1d826a834e8493ba0432cb
5
5
  SHA512:
6
- metadata.gz: 0641e7d194b1981985a8110e315d1caa19b19ae20ca21daac89b35ecb5a33cb1889bae67f27812d954c26fffada29bb166cab245e4e2257271f7032b91a758ad
7
- data.tar.gz: 680b3f0c891f5e7a1ad3a5eb359938e05fd428ac6b76f5403a880242ae3f40b4a04b81a99032f432fafc49237e5732f9a1c276cbc50b2e1ce33be761e357bac7
6
+ metadata.gz: fff818a9427ae13526871ba23b78c1bd1f5a91731a14bbee503a8c547df397ab8fda5dfd04d13f5e72cbd70488bce4d4ee51783c6a3c3f8e1f808bddd188a83f
7
+ data.tar.gz: facfc66055775d9cd3393f9446591716386f9e82b9cc247ed210fe5bb02c51e3eb83ce956c8ed9dca02560982c30f9fa9ea78ea8508d7a3d49d3d8895cbac591
@@ -19,7 +19,7 @@ module MailAddress
19
19
  @phrase = original if @address.nil?
20
20
  end
21
21
 
22
- ATEXT = '[\-\w !#$%&\'*+/=?^`{|}~]'
22
+ ATEXT = '[\-\w\s!#$%&\'*+/=?^`{|}~]'
23
23
 
24
24
  def format(enquote = false)
25
25
  addr = []
@@ -27,19 +27,19 @@ module MailAddress
27
27
 
28
28
  email_address = enquote ? quoted_address : @address
29
29
 
30
- if !@phrase.nil? && @phrase.length > 0 then
30
+ if !@phrase.nil? && @phrase.length > 0
31
31
  # if @phrase.match(/\A\(/) && @phrase.match(/\)\z/)
32
32
  # addr.push(email_address) if !@address.nil? && @address.length > 0
33
33
  # addr.push(@phrase)
34
34
  # else
35
35
  addr.push(
36
- @phrase.match(/^(?:\s*#{ATEXT}\s*)+$/) ? @phrase
37
- : @phrase.match(/(?<!\\)"/) ? @phrase
36
+ @phrase.match(/^(?:#{ATEXT})+$/) ? @phrase
37
+ : @phrase.match(/(?<!\\)"/) ? @phrase
38
38
  : %Q("#{@phrase}")
39
39
  )
40
40
  addr.push "<#{email_address}>" if !@address.nil? && @address.length > 0
41
41
  # end
42
- elsif !@address.nil? && @address.length > 0 then
42
+ elsif !@address.nil? && @address.length > 0
43
43
  addr.push(email_address)
44
44
  end
45
45
  addr.join(' ')
@@ -37,7 +37,7 @@ module MailAddress
37
37
  next
38
38
  end
39
39
 
40
- if (substr == '(' && !address.empty?) then
40
+ if (substr == '(' && !address.empty?)
41
41
  end_paren_idx = _find_next_paren(idx, tokens, len)
42
42
  if end_paren_idx == -1
43
43
  # end paren doesn't exist
@@ -45,11 +45,11 @@ module MailAddress
45
45
  end
46
46
  rem = tokens[idx .. end_paren_idx]
47
47
  phrase.push(rem.join(''))
48
- elsif (substr == '<') then
48
+ elsif (substr == '<')
49
49
  depth += 1
50
- elsif (substr == '>') then
50
+ elsif (substr == '>')
51
51
  depth -= 1 if depth > 0
52
- elsif (substr == ',' || substr == ';') then
52
+ elsif (substr == ',' || substr == ';')
53
53
  original.sub!(/[,;]\s*\z/, '')
54
54
 
55
55
  if depth > 0
@@ -65,12 +65,12 @@ module MailAddress
65
65
  end_paren_idx = 0
66
66
  original = ''
67
67
  _next = _find_next idx+1, tokens, len
68
- elsif (depth > 0) then
68
+ elsif (depth > 0)
69
69
  token.strip!
70
70
  address.push(token)
71
- elsif (_next == '<') then
71
+ elsif (_next == '<')
72
72
  phrase.push(token)
73
- elsif ( token.match(/^[.\@:;]/) || address.empty? || address[-1].match(/^[.\@:;]/) ) then
73
+ elsif ( token.match(/^[.\@:;]/) || address.empty? || address[-1].match(/^[.\@:;]/) )
74
74
  token.strip!
75
75
  address.push(token)
76
76
  else
@@ -1,3 +1,3 @@
1
1
  module MailAddress
2
- VERSION = "1.2.15"
2
+ VERSION = "1.2.16"
3
3
  end
@@ -3,6 +3,13 @@ require 'pp'
3
3
 
4
4
  describe MailAddress do
5
5
 
6
+ it "long address takes long time to format" do
7
+ aaa15 = "aaa " * 15
8
+ line = "\"#{aaa15} https://aaa.com\" <example@example.jp>"
9
+ result = MailAddress.parse_first(line)
10
+ expect(result.format).not_to be_nil # takes 5s at version 1.2.15
11
+ end
12
+
6
13
  it "normal case (commonly used)" do
7
14
  # address only
8
15
  line = 'johndoe@example.com'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.15
4
+ version: 1.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kizashi Nagata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler