safe_email_name 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/safe_email_name.rb +11 -8
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef4931c824880cc5166d0934a5460d628652beed
|
4
|
+
data.tar.gz: '099909bd0b3df0a36022618dab95ffff87247d39'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89a2bd984fc06f251d19028116a98a8d374fa9d8b574fe1eeec08117a0ce2159ede5b5937b6a3f8b8340df5af5b5bb1bb5e321a4aa3982a431ba6bccc7cf58c7
|
7
|
+
data.tar.gz: ff8395f0d3c9bba8c0a833f19d065a676dfc19ed1027a48fc7714d1ce64817ec47ae5eafc2a4ca26dae848db589f694da29dd446913328393856c3ea9daba36a
|
data/lib/safe_email_name.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
+
require 'mail'
|
1
2
|
require 'active_support'
|
2
3
|
require 'active_support/core_ext/object/blank'
|
3
4
|
require 'active_support/core_ext/string/filters' # squish
|
4
5
|
|
5
6
|
module SafeEmailName
|
7
|
+
REMOVED_EMAIL_CHARACTERS = /[<>"]+/.freeze
|
8
|
+
private_constant :REMOVED_EMAIL_CHARACTERS
|
9
|
+
|
6
10
|
def safe_email_name(name, email)
|
7
|
-
|
11
|
+
email = email.gsub(REMOVED_EMAIL_CHARACTERS, '')
|
12
|
+
name = name.to_s.squish
|
13
|
+
return email if name.blank?
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
"#{name} <#{email}>"
|
15
|
-
end
|
15
|
+
address = Mail::Address.new
|
16
|
+
address.display_name = name
|
17
|
+
address.address = email
|
18
|
+
address.to_s
|
16
19
|
end
|
17
20
|
|
18
21
|
# Make method available as a class method as well.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_email_name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mail
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activesupport
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,9 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
80
|
version: '0'
|
67
81
|
requirements: []
|
68
82
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.5.2.3
|
70
84
|
signing_key:
|
71
85
|
specification_version: 4
|
72
86
|
summary: Escape To and From fields in emails
|
73
87
|
test_files: []
|
74
|
-
has_rdoc:
|