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 +4 -4
- data/lib/mail_address/address.rb +5 -5
- data/lib/mail_address/mail_address.rb +7 -7
- data/lib/mail_address/version.rb +1 -1
- data/spec/mail_address_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9444cdca2ba62456c8945411801b4dca251a7d44
|
4
|
+
data.tar.gz: a939e18eaab3b80c2a1d826a834e8493ba0432cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fff818a9427ae13526871ba23b78c1bd1f5a91731a14bbee503a8c547df397ab8fda5dfd04d13f5e72cbd70488bce4d4ee51783c6a3c3f8e1f808bddd188a83f
|
7
|
+
data.tar.gz: facfc66055775d9cd3393f9446591716386f9e82b9cc247ed210fe5bb02c51e3eb83ce956c8ed9dca02560982c30f9fa9ea78ea8508d7a3d49d3d8895cbac591
|
data/lib/mail_address/address.rb
CHANGED
@@ -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
|
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(/^(
|
37
|
-
: @phrase.match(/(?<!\\)"/)
|
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
|
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?)
|
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 == '<')
|
48
|
+
elsif (substr == '<')
|
49
49
|
depth += 1
|
50
|
-
elsif (substr == '>')
|
50
|
+
elsif (substr == '>')
|
51
51
|
depth -= 1 if depth > 0
|
52
|
-
elsif (substr == ',' || substr == ';')
|
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)
|
68
|
+
elsif (depth > 0)
|
69
69
|
token.strip!
|
70
70
|
address.push(token)
|
71
|
-
elsif (_next == '<')
|
71
|
+
elsif (_next == '<')
|
72
72
|
phrase.push(token)
|
73
|
-
elsif ( token.match(/^[.\@:;]/) || address.empty? || address[-1].match(/^[.\@:;]/) )
|
73
|
+
elsif ( token.match(/^[.\@:;]/) || address.empty? || address[-1].match(/^[.\@:;]/) )
|
74
74
|
token.strip!
|
75
75
|
address.push(token)
|
76
76
|
else
|
data/lib/mail_address/version.rb
CHANGED
data/spec/mail_address_spec.rb
CHANGED
@@ -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.
|
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
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|