sanitize_email 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +55 -14
- data/Appraisals +55 -0
- data/CHANGELOG.md +1 -1
- data/README.md +21 -2
- data/Rakefile +5 -38
- data/gemfiles/rails_3_0.gemfile +12 -0
- data/gemfiles/rails_3_1.gemfile +13 -0
- data/gemfiles/rails_3_2.gemfile +11 -0
- data/gemfiles/rails_4_0.gemfile +11 -0
- data/gemfiles/rails_4_1.gemfile +11 -0
- data/gemfiles/rails_4_2.gemfile +10 -0
- data/gemfiles/rails_5_0.gemfile +10 -0
- data/init.rb +1 -1
- data/lib/sanitize_email/config.rb +30 -13
- data/lib/sanitize_email/mail_header_tools.rb +30 -11
- data/lib/sanitize_email/overridden_addresses.rb +5 -5
- data/lib/sanitize_email/rspec_matchers.rb +48 -29
- data/lib/sanitize_email/test_helpers.rb +16 -10
- data/lib/sanitize_email/version.rb +1 -1
- data/lib/sanitize_email.rb +24 -21
- data/sanitize_email.gemspec +2 -0
- data/spec/sanitize_email_spec.rb +521 -220
- data/spec/spec_helper.rb +9 -9
- metadata +39 -9
- data/gemfiles/Gemfile.rails-3.0.x +0 -7
- data/gemfiles/Gemfile.rails-3.1.x +0 -8
- data/gemfiles/Gemfile.rails-3.2.x +0 -9
- data/gemfiles/Gemfile.rails-4.0.x +0 -9
- data/gemfiles/Gemfile.rails-4.1.x +0 -9
- data/gemfiles/Gemfile.rails-4.2.x +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 289e6af15ea68e8b10617cc2803055254cca058a
|
4
|
+
data.tar.gz: 4404c4335975e05532e2ada1a12f447687aef097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c38011a2de7fb6317130462b6ab153b041e46eee7fc2eab19250899dd260ab49b4d962d648cfa529d5df24f003632098bbfd5078956c5b496c1b0f778990c49
|
7
|
+
data.tar.gz: 15a4766d74108c6ab0e076a328fe0a359972b550281038d260ad87488e5d2f56e1dc5f1e9cd027ffeb10a88a926f535c10df84940fa8b1e3042d6b60fed9b8ca
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.3.1
|
data/.travis.yml
CHANGED
@@ -2,26 +2,67 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
4
|
rvm:
|
5
|
+
# - 1.9
|
5
6
|
- 2.0
|
6
7
|
- 2.1
|
7
8
|
- 2.2
|
8
|
-
-
|
9
|
+
- 2.3.1
|
10
|
+
# - ruby-head
|
9
11
|
gemfile:
|
10
|
-
- gemfiles/
|
11
|
-
- gemfiles/
|
12
|
-
- gemfiles/
|
13
|
-
- gemfiles/
|
12
|
+
- gemfiles/rails_3_0.gemfile
|
13
|
+
- gemfiles/rails_3_1.gemfile
|
14
|
+
- gemfiles/rails_3_2.gemfile
|
15
|
+
- gemfiles/rails_4_0.gemfile
|
16
|
+
- gemfiles/rails_4_1.gemfile
|
17
|
+
- gemfiles/rails_4_2.gemfile
|
18
|
+
- gemfiles/rails_5_0.gemfile
|
14
19
|
matrix:
|
15
20
|
allow_failures:
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: 1.9
|
21
|
+
# - rvm: ruby-head
|
22
|
+
# - rvm: 1.9
|
18
23
|
exclude:
|
19
|
-
- rvm: 2.0
|
20
|
-
gemfile: gemfiles/Gemfile.rails-4.2.x
|
21
|
-
- rvm: 2.1
|
22
|
-
gemfile: gemfiles/Gemfile.rails-4.2.x
|
23
|
-
include:
|
24
24
|
- rvm: 1.9
|
25
|
-
gemfile: gemfiles/
|
25
|
+
gemfile: gemfiles/rails_3_2.gemfile
|
26
|
+
- rvm: 1.9
|
27
|
+
gemfile: gemfiles/rails_4_0.gemfile
|
26
28
|
- rvm: 1.9
|
27
|
-
gemfile: gemfiles/
|
29
|
+
gemfile: gemfiles/rails_4_1.gemfile
|
30
|
+
- rvm: 1.9
|
31
|
+
gemfile: gemfiles/rails_4_2.gemfile
|
32
|
+
- rvm: 1.9
|
33
|
+
gemfile: gemfiles/rails_5_0.gemfile
|
34
|
+
- rvm: 2.0
|
35
|
+
gemfile: gemfiles/rails_3_0.gemfile
|
36
|
+
- rvm: 2.0
|
37
|
+
gemfile: gemfiles/rails_3_1.gemfile
|
38
|
+
- rvm: 2.0
|
39
|
+
gemfile: gemfiles/rails_4_2.gemfile
|
40
|
+
- rvm: 2.0
|
41
|
+
gemfile: gemfiles/rails_5_0.gemfile
|
42
|
+
- rvm: 2.1
|
43
|
+
gemfile: gemfiles/rails_3_0.gemfile
|
44
|
+
- rvm: 2.1
|
45
|
+
gemfile: gemfiles/rails_3_1.gemfile
|
46
|
+
- rvm: 2.1
|
47
|
+
gemfile: gemfiles/rails_4_2.gemfile
|
48
|
+
- rvm: 2.1
|
49
|
+
gemfile: gemfiles/rails_5_0.gemfile
|
50
|
+
- rvm: 2.2
|
51
|
+
gemfile: gemfiles/rails_3_0.gemfile
|
52
|
+
- rvm: 2.2
|
53
|
+
gemfile: gemfiles/rails_3_1.gemfile
|
54
|
+
- rvm: 2.2
|
55
|
+
gemfile: gemfiles/rails_5_0.gemfile
|
56
|
+
- rvm: 2.3.1
|
57
|
+
gemfile: gemfiles/rails_3_0.gemfile
|
58
|
+
- rvm: 2.3.1
|
59
|
+
gemfile: gemfiles/rails_3_1.gemfile
|
60
|
+
# - rvm: ruby-head
|
61
|
+
# gemfile: gemfiles/rails_5_0.gemfile
|
62
|
+
# include:
|
63
|
+
# - rvm: 1.9
|
64
|
+
# gemfile: gemfiles/rails_3_0.gemfile
|
65
|
+
# - rvm: 1.9
|
66
|
+
# gemfile: gemfiles/rails_3_1.gemfile
|
67
|
+
install:
|
68
|
+
- bundle install
|
data/Appraisals
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
appraise "rails-3-0" do
|
2
|
+
gem "rails", "~> 3.0.0"
|
3
|
+
gem "reek", "~> 2.0" # for Ruby < 2.0
|
4
|
+
gem "tins", "~> 1.6.0" # for Ruby < 2.0
|
5
|
+
gem "json", "~> 1.8.3"
|
6
|
+
gem "rake", "~> 11.2.2"
|
7
|
+
gem "rest-client", "~> 1.8.0"
|
8
|
+
end
|
9
|
+
appraise "rails-3-1" do
|
10
|
+
gem "actionmailer", "~> 3.1.0"
|
11
|
+
gem "railties", "~> 3.1.0"
|
12
|
+
gem "reek", "~> 2.0" # for Ruby < 2.0
|
13
|
+
gem "tins", "~> 1.6.0" # for Ruby < 2.0
|
14
|
+
gem "json", "~> 1.8.3"
|
15
|
+
gem "rake", "~> 11.2.2"
|
16
|
+
gem "rest-client", "~> 1.8.0"
|
17
|
+
end
|
18
|
+
appraise "rails-3-2" do
|
19
|
+
gem "actionmailer", "~> 3.2.0"
|
20
|
+
gem "railties", "~> 3.2.0"
|
21
|
+
# reek >= 4.0 requires Ruby 2.1 minimum
|
22
|
+
gem "reek", "~>3.11.0"
|
23
|
+
gem "json", "~> 1.8.3"
|
24
|
+
gem "rake", "~> 11.2.2"
|
25
|
+
end
|
26
|
+
|
27
|
+
appraise "rails-4-0" do
|
28
|
+
gem "actionmailer", "~> 4.0.0"
|
29
|
+
gem "railties", "~> 4.0.0"
|
30
|
+
# reek >= 4.0 requires Ruby 2.1 minimum
|
31
|
+
gem "reek", "~>3.11.0"
|
32
|
+
gem "json", "~> 1.8.3"
|
33
|
+
gem "rake", "~> 11.2.2"
|
34
|
+
end
|
35
|
+
appraise "rails-4-1" do
|
36
|
+
gem "actionmailer", "~> 4.1.0"
|
37
|
+
gem "railties", "~> 4.1.0"
|
38
|
+
# reek >= 4.0 requires Ruby 2.1 minimum
|
39
|
+
gem "reek", "~>3.11.0"
|
40
|
+
gem "json", "~> 1.8.3"
|
41
|
+
gem "rake", "~> 11.2.2"
|
42
|
+
end
|
43
|
+
appraise "rails-4-2" do
|
44
|
+
gem "actionmailer", "~> 4.2.0"
|
45
|
+
gem "railties", "~> 4.2.0"
|
46
|
+
gem "json", "~> 1.8.3"
|
47
|
+
gem "rake", "~> 11.2.2"
|
48
|
+
end
|
49
|
+
|
50
|
+
appraise "rails-5-0" do
|
51
|
+
gem "actionmailer", "~> 5.0.0"
|
52
|
+
gem "railties", "~> 5.0.0"
|
53
|
+
gem "json", "~> 2.0.2"
|
54
|
+
gem "rake", "~> 11.2.2"
|
55
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
HEAD
|
2
2
|
|
3
|
-
Version 1.2.0- JUL.24.2016
|
3
|
+
Version 1.2.0 - JUL.24.2016
|
4
4
|
* No longer registers instance of SanitizeEmail::Bleach to avoid the dev env reloading problem (fixes #12)
|
5
5
|
* Instead registers SanitizeEmail::Bleach class.
|
6
6
|
* Deprecate sending arguments to SanitizeEmail::Bleach.new
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ This gem allows you to override your mail delivery settings, globally or in a lo
|
|
17
17
|
| homepage | [http://www.railsbling.com/tags/sanitize_email/][homepage] |
|
18
18
|
| documentation | [http://rdoc.info/github/pboling/sanitize_email/frames][documentation] |
|
19
19
|
| live chat | [![Join the chat at https://gitter.im/pboling/sanitize_email](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pboling/sanitize_email?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
|
20
|
-
| Spread ~♡ⓛⓞⓥⓔ♡~ | [
|
20
|
+
| Spread ~♡ⓛⓞⓥⓔ♡~ | [AngeList](https://angel.co/peter-boling), [on Coderwall](http://coderwall.com/pboling), [on TopCoder](https://www.topcoder.com/members/pboling/) |
|
21
21
|
|
22
22
|
## Summary
|
23
23
|
|
@@ -338,6 +338,25 @@ Follow the instructions for "Contributing" below.
|
|
338
338
|
5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
339
339
|
6. Create new Pull Request
|
340
340
|
|
341
|
+
## Running Specs
|
342
|
+
|
343
|
+
The basic compatibility matrix:
|
344
|
+
```
|
345
|
+
appraisal install
|
346
|
+
appraisal rake test
|
347
|
+
```
|
348
|
+
|
349
|
+
Run the whole travis compatibility matrix:
|
350
|
+
```
|
351
|
+
rake wwtd:bundle
|
352
|
+
rake wwtd
|
353
|
+
```
|
354
|
+
|
355
|
+
Sometimes also:
|
356
|
+
```
|
357
|
+
appraisal update
|
358
|
+
```
|
359
|
+
|
341
360
|
## Versioning
|
342
361
|
|
343
362
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
@@ -353,7 +372,7 @@ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two
|
|
353
372
|
For example:
|
354
373
|
|
355
374
|
```ruby
|
356
|
-
spec.add_dependency 'sanitize_email', '~> 1.
|
375
|
+
spec.add_dependency 'sanitize_email', '~> 1.3'
|
357
376
|
```
|
358
377
|
|
359
378
|
## References
|
data/Rakefile
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#!/usr/bin/env rake
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
3
5
|
require "bundler/gem_tasks"
|
4
6
|
require "rake"
|
5
7
|
|
6
8
|
begin
|
9
|
+
require "wwtd/tasks"
|
7
10
|
require "rspec/core/rake_task"
|
8
11
|
RSpec::Core::RakeTask.new(:spec)
|
9
12
|
task :default => :spec
|
13
|
+
task :test => :spec
|
10
14
|
rescue LoadError
|
15
|
+
warn "Failed to load rspec or wwtd"
|
11
16
|
end
|
12
17
|
|
13
18
|
require "reek/rake/task"
|
@@ -23,44 +28,6 @@ RoodiTask.new do |t|
|
|
23
28
|
t.verbose = false
|
24
29
|
end
|
25
30
|
|
26
|
-
namespace :test do
|
27
|
-
desc "Test against all supported Rails versions"
|
28
|
-
task :all do
|
29
|
-
%w(3.0.x 3.1.x 3.2.x 4.0.x).each do |version|
|
30
|
-
system(<<-EOS
|
31
|
-
bash -i -c "rvm use 1.9.3"
|
32
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
|
33
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
|
34
|
-
EOS
|
35
|
-
)
|
36
|
-
end
|
37
|
-
%w(3.2.x 4.0.x 4.1.x).each do |version|
|
38
|
-
system(<<-EOS
|
39
|
-
bash -i -c "rvm use 2.0.0"
|
40
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
|
41
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
|
42
|
-
EOS
|
43
|
-
)
|
44
|
-
end
|
45
|
-
%w(3.2.x 4.0.x 4.1.x).each do |version|
|
46
|
-
system(<<-EOS
|
47
|
-
bash -i -c "rvm use 2.1.7"
|
48
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
|
49
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
|
50
|
-
EOS
|
51
|
-
)
|
52
|
-
end
|
53
|
-
%w(3.2.x 4.0.x 4.1.x 4.2.x).each do |version|
|
54
|
-
system(<<-EOS
|
55
|
-
bash -i -c "rvm use 2.2.3"
|
56
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
|
57
|
-
BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
|
58
|
-
EOS
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
31
|
require File.expand_path("../lib/sanitize_email/version", __FILE__)
|
65
32
|
require "rdoc"
|
66
33
|
require "rdoc/task"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 3.0.0"
|
6
|
+
gem "reek", "~> 2.0"
|
7
|
+
gem "tins", "~> 1.6.0"
|
8
|
+
gem "json", "~> 1.8.3"
|
9
|
+
gem "rake", "~> 11.2.2"
|
10
|
+
gem "rest-client", "~> 1.8.0"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "actionmailer", "~> 3.1.0"
|
6
|
+
gem "railties", "~> 3.1.0"
|
7
|
+
gem "reek", "~> 2.0"
|
8
|
+
gem "tins", "~> 1.6.0"
|
9
|
+
gem "json", "~> 1.8.3"
|
10
|
+
gem "rake", "~> 11.2.2"
|
11
|
+
gem "rest-client", "~> 1.8.0"
|
12
|
+
|
13
|
+
gemspec :path => "../"
|
data/init.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
1
|
+
require "sanitize_email"
|
2
2
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module SanitizeEmail
|
5
5
|
# The API for configuring SanitizeEmail is via `SanitizeEmail.config`
|
6
|
-
# Available configuration options are listed in the `DEFAULTS
|
6
|
+
# Available configuration options are listed in the `DEFAULTS` constant.
|
7
7
|
class Config
|
8
8
|
|
9
9
|
extend SanitizeEmail::Deprecation
|
@@ -13,14 +13,18 @@ module SanitizeEmail
|
|
13
13
|
end
|
14
14
|
|
15
15
|
DEFAULTS = {
|
16
|
-
# Specify the BCC addresses for the messages
|
16
|
+
# Specify the BCC addresses for the messages
|
17
|
+
# that go out in "local" environments
|
17
18
|
:sanitized_bcc => nil,
|
18
19
|
|
19
|
-
# Specify the CC addresses for the messages
|
20
|
+
# Specify the CC addresses for the messages
|
21
|
+
# that go out in "local" environments
|
20
22
|
:sanitized_cc => nil,
|
21
23
|
|
22
|
-
# The recipient addresses for the messages,
|
23
|
-
#
|
24
|
+
# The recipient addresses for the messages,
|
25
|
+
# either as a string (for a single address)
|
26
|
+
# or an array (for multiple addresses)
|
27
|
+
# that go out in "local" environments
|
24
28
|
:sanitized_to => nil,
|
25
29
|
|
26
30
|
# a white list
|
@@ -29,13 +33,18 @@ module SanitizeEmail
|
|
29
33
|
# a black list
|
30
34
|
:bad_list => nil,
|
31
35
|
|
32
|
-
:environment => defined?(Rails) && Rails.env.present?
|
36
|
+
:environment => if defined?(Rails) && Rails.env.present?
|
37
|
+
("[" << Rails.env << "]")
|
38
|
+
else
|
39
|
+
"[UNKNOWN ENVIRONMENT]"
|
40
|
+
end,
|
33
41
|
|
34
|
-
# Use the
|
42
|
+
# Use the "real" email address as the username
|
43
|
+
# for the sanitized email address
|
35
44
|
# e.g. "real@example.com <sanitized@example.com>"
|
36
45
|
:use_actual_email_as_sanitized_user_name => false,
|
37
46
|
|
38
|
-
# Prepend the
|
47
|
+
# Prepend the "real" email address onto the Subject line of the message
|
39
48
|
# e.g. "real@example.com rest of subject"
|
40
49
|
:use_actual_email_prepended_to_subject => false,
|
41
50
|
|
@@ -43,6 +52,10 @@ module SanitizeEmail
|
|
43
52
|
# e.g. "[development] rest of subject"
|
44
53
|
:use_actual_environment_prepended_to_subject => false,
|
45
54
|
|
55
|
+
# True / False turns on or off sanitization,
|
56
|
+
# while nil ignores this setting and checks activation_proc
|
57
|
+
:engage => nil,
|
58
|
+
|
46
59
|
:activation_proc => Proc.new { false }
|
47
60
|
}
|
48
61
|
|
@@ -51,14 +64,18 @@ module SanitizeEmail
|
|
51
64
|
yield @config
|
52
65
|
|
53
66
|
# Gracefully handle deprecated config values.
|
54
|
-
# Actual deprecation warnings are thrown in the top SanitizeEmail module
|
67
|
+
# Actual deprecation warnings are thrown in the top SanitizeEmail module
|
68
|
+
# thanks to our use of dynamic methods.
|
55
69
|
if @config[:local_environments] && defined?(Rails)
|
56
|
-
@config[:activation_proc] = Proc.new {
|
70
|
+
@config[:activation_proc] = Proc.new {
|
71
|
+
SanitizeEmail.local_environments.include?(Rails.env)
|
72
|
+
}
|
57
73
|
end
|
58
74
|
if @config[:sanitized_recipients]
|
59
|
-
|
60
|
-
|
61
|
-
|
75
|
+
# calling it to trigger the deprecation warning.
|
76
|
+
# Won't actually be set with any value,
|
77
|
+
# because we are still inside the configure block.
|
78
|
+
SanitizeEmail.sanitized_recipients
|
62
79
|
@config[:sanitized_to] = @config[:sanitized_recipients]
|
63
80
|
end
|
64
81
|
if !@config[:force_sanitize].nil?
|
@@ -7,9 +7,16 @@ module SanitizeEmail
|
|
7
7
|
|
8
8
|
def self.prepend_subject_array(message)
|
9
9
|
prepend = []
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if SanitizeEmail.use_actual_email_prepended_to_subject
|
11
|
+
prepend << SanitizeEmail::MailHeaderTools.
|
12
|
+
prepend_email_to_subject(Array(message.to))
|
13
|
+
end
|
14
|
+
if SanitizeEmail.use_actual_environment_prepended_to_subject
|
15
|
+
prepend << SanitizeEmail::MailHeaderTools.
|
16
|
+
prepend_environment_to_subject
|
17
|
+
end
|
18
|
+
# this will force later joins to add an extra space
|
19
|
+
prepend << "" unless prepend.empty?
|
13
20
|
prepend
|
14
21
|
end
|
15
22
|
|
@@ -22,27 +29,39 @@ module SanitizeEmail
|
|
22
29
|
end
|
23
30
|
|
24
31
|
def self.prepend_email_to_subject(actual_addresses)
|
25
|
-
"(#{actual_addresses.uniq.join(',').gsub(/@/, ' at ').
|
32
|
+
"(#{Array(actual_addresses).uniq.join(',').gsub(/@/, ' at ').
|
33
|
+
gsub(/[<>]/, '~')})"
|
26
34
|
end
|
27
35
|
|
28
36
|
def self.add_original_addresses_as_headers(message)
|
29
|
-
|
37
|
+
# Add headers by string concat.
|
38
|
+
# Setting hash values on message.headers does nothing, strangely.
|
39
|
+
# See: http://goo.gl/v46GY
|
30
40
|
{
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
# can be an arrays, so casting it as arrays
|
42
|
+
"X-Sanitize-Email-To" => Array(message.to).uniq,
|
43
|
+
"X-Sanitize-Email-Cc" => Array(message.cc).uniq
|
44
|
+
# Don't write out the BCC, as those addresses should not be visible
|
45
|
+
# in message headers for obvious reasons
|
34
46
|
}.each { |header_key, header_value|
|
35
47
|
# For each type of address line
|
36
|
-
SanitizeEmail::MailHeaderTools.update_header(
|
48
|
+
SanitizeEmail::MailHeaderTools.update_header(
|
49
|
+
header_key,
|
50
|
+
header_value,
|
51
|
+
message
|
52
|
+
)
|
37
53
|
}
|
38
54
|
end
|
39
55
|
|
40
56
|
def self.prepend_custom_subject(message)
|
41
57
|
message.subject = "" unless message.subject
|
42
|
-
message.subject.prepend(
|
58
|
+
message.subject.prepend(
|
59
|
+
SanitizeEmail::MailHeaderTools.custom_subject(message)
|
60
|
+
)
|
43
61
|
end
|
44
62
|
|
45
|
-
# According to https://github.com/mikel/mail
|
63
|
+
# According to https://github.com/mikel/mail
|
64
|
+
# this is the correct way to update headers.
|
46
65
|
def self.update_header(header_key, header_value, message)
|
47
66
|
# For each address, as header_value can be an array of addresses
|
48
67
|
Array(header_value).each_with_index { |elem, index|
|
@@ -42,15 +42,15 @@ module SanitizeEmail
|
|
42
42
|
def to_override(actual_addresses)
|
43
43
|
to = override_email(:to, actual_addresses)
|
44
44
|
raise MissingTo, "after overriding :to (#{actual_addresses}) there are no addresses to send in To: header." if to.empty?
|
45
|
-
to.join(
|
45
|
+
to.join(",")
|
46
46
|
end
|
47
47
|
|
48
48
|
def cc_override(actual_addresses)
|
49
|
-
override_email(:cc, actual_addresses).join(
|
49
|
+
override_email(:cc, actual_addresses).join(",")
|
50
50
|
end
|
51
51
|
|
52
52
|
def bcc_override(actual_addresses)
|
53
|
-
override_email(:bcc, actual_addresses).join(
|
53
|
+
override_email(:bcc, actual_addresses).join(",")
|
54
54
|
end
|
55
55
|
|
56
56
|
def override_email(type, actual_addresses)
|
@@ -78,14 +78,14 @@ module SanitizeEmail
|
|
78
78
|
sanitized_addresses = self.clean_addresses(sanitized_addresses, :bad_list)
|
79
79
|
#puts "override_email 5: #{type} - #{sanitized_addresses}"
|
80
80
|
|
81
|
-
# If we don't want to inject the
|
81
|
+
# If we don't want to inject the "email" in the "user name" section of the sanitized recipients,
|
82
82
|
# then just return the default sanitized recipients
|
83
83
|
return sanitized_addresses unless SanitizeEmail.use_actual_email_as_sanitized_user_name
|
84
84
|
|
85
85
|
with_user_names = self.inject_user_names(real_addresses, sanitized_addresses)
|
86
86
|
#puts "real_addresses 2: #{real_addresses}"
|
87
87
|
#puts "override_email 6: #{type} - #{with_user_names}"
|
88
|
-
# Otherwise inject the email as the
|
88
|
+
# Otherwise inject the email as the "user name"
|
89
89
|
return with_user_names
|
90
90
|
end
|
91
91
|
|