sanitize_email 2.0.9 → 2.0.11
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +175 -41
- data/CITATION.cff +20 -0
- data/CODE_OF_CONDUCT.md +79 -29
- data/CONTRIBUTING.md +233 -46
- data/FUNDING.md +63 -0
- data/LICENSE.md +22 -0
- data/README.md +393 -614
- data/RUBOCOP.md +71 -0
- data/SECURITY.md +15 -9
- data/certs/pboling.pem +27 -0
- data/lib/sanitize_email/bleach.rb +3 -1
- data/lib/sanitize_email/config.rb +51 -34
- data/lib/sanitize_email/deprecation.rb +9 -1
- data/lib/sanitize_email/mail_ext.rb +8 -6
- data/lib/sanitize_email/mail_header_tools.rb +64 -61
- data/lib/sanitize_email/rspec_matchers.rb +1 -1
- data/lib/sanitize_email/version.rb +2 -4
- data/lib/sanitize_email.rb +20 -10
- data/sig/sanitize_email/version.rbs +6 -0
- data.tar.gz.sig +0 -0
- metadata +207 -51
- metadata.gz.sig +0 -0
- data/LICENSE.txt +0 -21
data/RUBOCOP.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# RuboCop Usage Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A tale of two RuboCop plugin gems.
|
|
6
|
+
|
|
7
|
+
### RuboCop Gradual
|
|
8
|
+
|
|
9
|
+
This project uses `rubocop_gradual` instead of vanilla RuboCop for code style checking. The `rubocop_gradual` tool allows for gradual adoption of RuboCop rules by tracking violations in a lock file.
|
|
10
|
+
|
|
11
|
+
### RuboCop LTS
|
|
12
|
+
|
|
13
|
+
This project uses `rubocop-lts` to ensure, on a best-effort basis, compatibility with Ruby >= 1.9.2.
|
|
14
|
+
RuboCop rules are meticulously configured by the `rubocop-lts` family of gems to ensure that a project is compatible with a specific version of Ruby. See: https://rubocop-lts.gitlab.io for more.
|
|
15
|
+
|
|
16
|
+
## Checking RuboCop Violations
|
|
17
|
+
|
|
18
|
+
To check for RuboCop violations in this project, always use:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bundle exec rake rubocop_gradual:check
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Do not use** the standard RuboCop commands like:
|
|
25
|
+
- `bundle exec rubocop`
|
|
26
|
+
- `rubocop`
|
|
27
|
+
|
|
28
|
+
## Understanding the Lock File
|
|
29
|
+
|
|
30
|
+
The `.rubocop_gradual.lock` file tracks all current RuboCop violations in the project. This allows the team to:
|
|
31
|
+
|
|
32
|
+
1. Prevent new violations while gradually fixing existing ones
|
|
33
|
+
2. Track progress on code style improvements
|
|
34
|
+
3. Ensure CI builds don't fail due to pre-existing violations
|
|
35
|
+
|
|
36
|
+
## Common Commands
|
|
37
|
+
|
|
38
|
+
- **Check violations**
|
|
39
|
+
- `bundle exec rake rubocop_gradual`
|
|
40
|
+
- `bundle exec rake rubocop_gradual:check`
|
|
41
|
+
- **(Safe) Autocorrect violations, and update lockfile if no new violations**
|
|
42
|
+
- `bundle exec rake rubocop_gradual:autocorrect`
|
|
43
|
+
- **Force update the lock file (w/o autocorrect) to match violations present in code**
|
|
44
|
+
- `bundle exec rake rubocop_gradual:force_update`
|
|
45
|
+
|
|
46
|
+
## Workflow
|
|
47
|
+
|
|
48
|
+
1. Before submitting a PR, run `bundle exec rake rubocop_gradual:autocorrect`
|
|
49
|
+
a. or just the default `bundle exec rake`, as autocorrection is a pre-requisite of the default task.
|
|
50
|
+
2. If there are new violations, either:
|
|
51
|
+
- Fix them in your code
|
|
52
|
+
- Run `bundle exec rake rubocop_gradual:force_update` to update the lock file (only for violations you can't fix immediately)
|
|
53
|
+
3. Commit the updated `.rubocop_gradual.lock` file along with your changes
|
|
54
|
+
|
|
55
|
+
## Never add inline RuboCop disables
|
|
56
|
+
|
|
57
|
+
Do not add inline `rubocop:disable` / `rubocop:enable` comments anywhere in the codebase (including specs, except when following the few existing `rubocop:disable` patterns for a rule already being disabled elsewhere in the code). We handle exceptions in two supported ways:
|
|
58
|
+
|
|
59
|
+
- Permanent/structural exceptions: prefer adjusting the RuboCop configuration (e.g., in `.rubocop.yml`) to exclude a rule for a path or file pattern when it makes sense project-wide.
|
|
60
|
+
- Temporary exceptions while improving code: record the current violations in `.rubocop_gradual.lock` via the gradual workflow:
|
|
61
|
+
- `bundle exec rake rubocop_gradual:autocorrect` (preferred; will autocorrect what it can and update the lock only if no new violations were introduced)
|
|
62
|
+
- If needed, `bundle exec rake rubocop_gradual:force_update` (as a last resort when you cannot fix the newly reported violations immediately)
|
|
63
|
+
|
|
64
|
+
In general, treat the rules as guidance to follow; fix violations rather than ignore them. For example, RSpec conventions in this project expect `described_class` to be used in specs that target a specific class under test.
|
|
65
|
+
|
|
66
|
+
## Benefits of rubocop_gradual
|
|
67
|
+
|
|
68
|
+
- Allows incremental adoption of code style rules
|
|
69
|
+
- Prevents CI failures due to pre-existing violations
|
|
70
|
+
- Provides a clear record of code style debt
|
|
71
|
+
- Enables focused efforts on improving code quality over time
|
data/SECURITY.md
CHANGED
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Versions
|
|
4
4
|
|
|
5
|
-
| Version
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
| 1.x | ❌ |
|
|
9
|
-
| 0.x | ❌ |
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
|----------|-----------|
|
|
7
|
+
| 1.latest | ✅ |
|
|
10
8
|
|
|
11
|
-
##
|
|
9
|
+
## Security contact information
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
To report a security vulnerability, please use the
|
|
12
|
+
[Tidelift security contact](https://tidelift.com/security).
|
|
13
|
+
Tidelift will coordinate the fix and disclosure.
|
|
14
|
+
|
|
15
|
+
## Additional Support
|
|
16
|
+
|
|
17
|
+
If you are interested in support for versions older than the latest release,
|
|
18
|
+
please consider sponsoring the project / maintainer @ https://liberapay.com/pboling/donate,
|
|
19
|
+
or find other sponsorship links in the [README].
|
|
20
|
+
|
|
21
|
+
[README]: README.md
|
data/certs/pboling.pem
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl
|
|
3
|
+
ci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
|
|
4
|
+
A2NvbTAeFw0yNTA1MDQxNTMzMDlaFw00NTA0MjkxNTMzMDlaMEMxFTATBgNVBAMM
|
|
5
|
+
DHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
|
|
6
|
+
LGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAruUoo0WA
|
|
7
|
+
uoNuq6puKWYeRYiZekz/nsDeK5x/0IEirzcCEvaHr3Bmz7rjo1I6On3gGKmiZs61
|
|
8
|
+
LRmQ3oxy77ydmkGTXBjruJB+pQEn7UfLSgQ0xa1/X3kdBZt6RmabFlBxnHkoaGY5
|
|
9
|
+
mZuZ5+Z7walmv6sFD9ajhzj+oIgwWfnEHkXYTR8I6VLN7MRRKGMPoZ/yvOmxb2DN
|
|
10
|
+
coEEHWKO9CvgYpW7asIihl/9GMpKiRkcYPm9dGQzZc6uTwom1COfW0+ZOFrDVBuV
|
|
11
|
+
FMQRPswZcY4Wlq0uEBLPU7hxnCL9nKK6Y9IhdDcz1mY6HZ91WImNslOSI0S8hRpj
|
|
12
|
+
yGOWxQIhBT3fqCBlRIqFQBudrnD9jSNpSGsFvbEijd5ns7Z9ZMehXkXDycpGAUj1
|
|
13
|
+
to/5cuTWWw1JqUWrKJYoifnVhtE1o1DZ+LkPtWxHtz5kjDG/zR3MG0Ula0UOavlD
|
|
14
|
+
qbnbcXPBnwXtTFeZ3C+yrWpE4pGnl3yGkZj9SMTlo9qnTMiPmuWKQDatAgMBAAGj
|
|
15
|
+
fzB9MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQE8uWvNbPVNRXZ
|
|
16
|
+
HlgPbc2PCzC4bjAhBgNVHREEGjAYgRZwZXRlci5ib2xpbmdAZ21haWwuY29tMCEG
|
|
17
|
+
A1UdEgQaMBiBFnBldGVyLmJvbGluZ0BnbWFpbC5jb20wDQYJKoZIhvcNAQELBQAD
|
|
18
|
+
ggGBAJbnUwfJQFPkBgH9cL7hoBfRtmWiCvdqdjeTmi04u8zVNCUox0A4gT982DE9
|
|
19
|
+
wmuN12LpdajxZONqbXuzZvc+nb0StFwmFYZG6iDwaf4BPywm2e/Vmq0YG45vZXGR
|
|
20
|
+
L8yMDSK1cQXjmA+ZBKOHKWavxP6Vp7lWvjAhz8RFwqF9GuNIdhv9NpnCAWcMZtpm
|
|
21
|
+
GUPyIWw/Cw/2wZp74QzZj6Npx+LdXoLTF1HMSJXZ7/pkxLCsB8m4EFVdb/IrW/0k
|
|
22
|
+
kNSfjtAfBHO8nLGuqQZVH9IBD1i9K6aSs7pT6TW8itXUIlkIUI2tg5YzW6OFfPzq
|
|
23
|
+
QekSkX3lZfY+HTSp/o+YvKkqWLUV7PQ7xh1ZYDtocpaHwgxe/j3bBqHE+CUPH2vA
|
|
24
|
+
0V/FwdTRWcwsjVoOJTrYcff8pBZ8r2MvtAc54xfnnhGFzeRHfcltobgFxkAXdE6p
|
|
25
|
+
DVjBtqT23eugOqQ73umLcYDZkc36vnqGxUBSsXrzY9pzV5gGr2I8YUxMqf6ATrZt
|
|
26
|
+
L9nRqA==
|
|
27
|
+
-----END CERTIFICATE-----
|
|
@@ -8,6 +8,7 @@ module SanitizeEmail
|
|
|
8
8
|
# and does so when appropriate.
|
|
9
9
|
class Bleach
|
|
10
10
|
extend SanitizeEmail::Deprecation
|
|
11
|
+
|
|
11
12
|
attr_accessor :overridden_addresses # TODO: Just a stub, not implemented
|
|
12
13
|
|
|
13
14
|
class << self
|
|
@@ -28,7 +29,8 @@ module SanitizeEmail
|
|
|
28
29
|
|
|
29
30
|
return if message["personalizations"].nil?
|
|
30
31
|
|
|
31
|
-
message["personalizations"]
|
|
32
|
+
message["personalizations"] = nil
|
|
33
|
+
message["personalizations"] = overridden.overridden_personalizations
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
# Will be called by the Hook to determine if an override should occur
|
|
@@ -9,9 +9,7 @@ module SanitizeEmail
|
|
|
9
9
|
class Config
|
|
10
10
|
extend SanitizeEmail::Deprecation
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
attr_accessor :config
|
|
14
|
-
end
|
|
12
|
+
CONFIG_MUTEX = Mutex.new
|
|
15
13
|
|
|
16
14
|
DEFAULTS = {
|
|
17
15
|
# Specify the BCC addresses for the messages
|
|
@@ -60,43 +58,62 @@ module SanitizeEmail
|
|
|
60
58
|
activation_proc: proc { false },
|
|
61
59
|
}.freeze
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
yield @config
|
|
61
|
+
INIT_KEYS = [:sanitized_to, :sanitized_cc, :sanitized_bcc, :good_list, :bad_list].freeze
|
|
62
|
+
@config = DEFAULTS.dup
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
class << self
|
|
65
|
+
def config
|
|
66
|
+
CONFIG_MUTEX.synchronize { @config }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def config=(value)
|
|
70
|
+
CONFIG_MUTEX.synchronize { @config = value }
|
|
74
71
|
end
|
|
75
|
-
|
|
72
|
+
|
|
73
|
+
def configure
|
|
74
|
+
sanitized_recipients = nil
|
|
75
|
+
|
|
76
|
+
CONFIG_MUTEX.synchronize do
|
|
77
|
+
yield @config
|
|
78
|
+
|
|
79
|
+
# Gracefully handle deprecated config values.
|
|
80
|
+
# Actual deprecation warnings are thrown in the top SanitizeEmail module
|
|
81
|
+
# thanks to our use of dynamic methods.
|
|
82
|
+
if @config[:local_environments] && defined?(Rails)
|
|
83
|
+
@config[:activation_proc] = proc do
|
|
84
|
+
SanitizeEmail.local_environments.include?(Rails.env)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
if @config[:sanitized_recipients]
|
|
88
|
+
sanitized_recipients = @config[:sanitized_recipients]
|
|
89
|
+
@config[:sanitized_to] = sanitized_recipients
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
76
93
|
# calling it to trigger the deprecation warning.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
SanitizeEmail.sanitized_recipients
|
|
80
|
-
@config[:sanitized_to] = @config[:sanitized_recipients]
|
|
94
|
+
SanitizeEmail.sanitized_recipients if sanitized_recipients
|
|
95
|
+
config_force_sanitize_deprecation_warning
|
|
81
96
|
end
|
|
82
|
-
config_force_sanitize_deprecation_warning
|
|
83
|
-
end
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
def config_force_sanitize_deprecation_warning
|
|
99
|
+
force_sanitize = CONFIG_MUTEX.synchronize { @config[:force_sanitize] }
|
|
100
|
+
return if force_sanitize.nil?
|
|
101
|
+
|
|
102
|
+
deprecation_warning_message(
|
|
103
|
+
<<-DEPRECATION,
|
|
104
|
+
SanitizeEmail::Config.config[:force_sanitize] is deprecated.
|
|
105
|
+
Please use SanitizeEmail.force_sanitize or SanitizeEmail.sanitary instead.
|
|
106
|
+
Refer to https://github.com/galtzo-floss/sanitize_email/wiki for examples.
|
|
107
|
+
DEPRECATION
|
|
108
|
+
)
|
|
109
|
+
SanitizeEmail.force_sanitize = force_sanitize
|
|
110
|
+
end
|
|
96
111
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
112
|
+
def to_init
|
|
113
|
+
CONFIG_MUTEX.synchronize do
|
|
114
|
+
@config.select { |key, _value| INIT_KEYS.include?(key) }
|
|
115
|
+
end
|
|
116
|
+
end
|
|
100
117
|
end
|
|
101
118
|
end
|
|
102
119
|
end
|
|
@@ -7,8 +7,16 @@ module SanitizeEmail
|
|
|
7
7
|
# Provides tools that allow methods to be deprecated with new releases of the gem.
|
|
8
8
|
# See http://www.seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
|
|
9
9
|
module Deprecation
|
|
10
|
+
DEPRECATE_IN_SILENCE_MUTEX = Mutex.new
|
|
11
|
+
|
|
10
12
|
class << self
|
|
11
|
-
|
|
13
|
+
def deprecate_in_silence
|
|
14
|
+
DEPRECATE_IN_SILENCE_MUTEX.synchronize { @deprecate_in_silence }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def deprecate_in_silence=(value)
|
|
18
|
+
DEPRECATE_IN_SILENCE_MUTEX.synchronize { @deprecate_in_silence = value }
|
|
19
|
+
end
|
|
12
20
|
end
|
|
13
21
|
|
|
14
22
|
@deprecate_in_silence = false
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
require "mail"
|
|
6
6
|
|
|
7
7
|
# Cribbed from email_spec gem
|
|
8
|
-
module SanitizeEmail
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
module SanitizeEmail
|
|
9
|
+
module MailExt
|
|
10
|
+
def default_part
|
|
11
|
+
@default_part ||= html_part || text_part || self
|
|
12
|
+
end
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
def default_part_body
|
|
15
|
+
default_part.body
|
|
16
|
+
end
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -6,77 +6,80 @@
|
|
|
6
6
|
module SanitizeEmail
|
|
7
7
|
# Tools for modifying the header of an email
|
|
8
8
|
module MailHeaderTools
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
class << self
|
|
10
|
+
def prepend_subject_array(message)
|
|
11
|
+
prepend = []
|
|
12
|
+
if SanitizeEmail.use_actual_email_prepended_to_subject
|
|
13
|
+
prepend << SanitizeEmail::MailHeaderTools
|
|
14
|
+
.prepend_email_to_subject(Array(message.to))
|
|
15
|
+
end
|
|
16
|
+
if SanitizeEmail.use_actual_environment_prepended_to_subject
|
|
17
|
+
prepend << SanitizeEmail::MailHeaderTools
|
|
18
|
+
.prepend_environment_to_subject
|
|
19
|
+
end
|
|
20
|
+
# this will force later joins to add an extra space
|
|
21
|
+
prepend << "" unless prepend.empty?
|
|
22
|
+
prepend
|
|
14
23
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
|
|
25
|
+
def custom_subject(message)
|
|
26
|
+
prepend_subject_array(message).join(" ")
|
|
18
27
|
end
|
|
19
|
-
# this will force later joins to add an extra space
|
|
20
|
-
prepend << "" unless prepend.empty?
|
|
21
|
-
prepend
|
|
22
|
-
end
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
def prepend_environment_to_subject
|
|
30
|
+
if SanitizeEmail::Config.config[:environment].respond_to?(:call)
|
|
31
|
+
SanitizeEmail::Config.config[:environment].call.to_s
|
|
32
|
+
else
|
|
33
|
+
SanitizeEmail::Config.config[:environment].to_s
|
|
34
|
+
end
|
|
35
|
+
end
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
else
|
|
32
|
-
SanitizeEmail::Config.config[:environment].to_s
|
|
37
|
+
def prepend_email_to_subject(actual_addresses)
|
|
38
|
+
"(#{Array(actual_addresses).uniq.join(",").gsub(/@/, " at ")
|
|
39
|
+
.gsub(/[<>]/, "~")})"
|
|
33
40
|
end
|
|
34
|
-
end
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
42
|
+
def add_original_addresses_as_headers(message)
|
|
43
|
+
# Add headers by string concat.
|
|
44
|
+
# Setting hash values on message.headers does nothing, strangely.
|
|
45
|
+
# See: http://goo.gl/v46GY
|
|
46
|
+
to_addrs = message[:to]&.addrs
|
|
47
|
+
cc_addrs = message[:cc]&.addrs
|
|
48
|
+
to_decoded = Array(to_addrs&.map(&:decoded))
|
|
49
|
+
cc_decoded = Array(cc_addrs&.map(&:decoded))
|
|
50
|
+
{
|
|
51
|
+
# can be an arrays, so casting it as arrays
|
|
52
|
+
"X-Sanitize-Email-To" => to_decoded,
|
|
53
|
+
"X-Sanitize-Email-Cc" => cc_decoded,
|
|
54
|
+
# Don't write out the BCC, as those addresses should not be visible
|
|
55
|
+
# in message headers for obvious reasons
|
|
56
|
+
}.each do |header_key, header_value|
|
|
57
|
+
# For each type of address line
|
|
58
|
+
SanitizeEmail::MailHeaderTools.update_header(
|
|
59
|
+
header_key,
|
|
60
|
+
header_value,
|
|
61
|
+
message,
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
40
65
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
to_addrs = message[:to]&.addrs
|
|
46
|
-
cc_addrs = message[:cc]&.addrs
|
|
47
|
-
to_decoded = Array(to_addrs&.map(&:decoded))
|
|
48
|
-
cc_decoded = Array(cc_addrs&.map(&:decoded))
|
|
49
|
-
{
|
|
50
|
-
# can be an arrays, so casting it as arrays
|
|
51
|
-
"X-Sanitize-Email-To" => to_decoded,
|
|
52
|
-
"X-Sanitize-Email-Cc" => cc_decoded,
|
|
53
|
-
# Don't write out the BCC, as those addresses should not be visible
|
|
54
|
-
# in message headers for obvious reasons
|
|
55
|
-
}.each do |header_key, header_value|
|
|
56
|
-
# For each type of address line
|
|
57
|
-
SanitizeEmail::MailHeaderTools.update_header(
|
|
58
|
-
header_key,
|
|
59
|
-
header_value,
|
|
60
|
-
message,
|
|
61
|
-
)
|
|
66
|
+
def prepend_custom_subject(message)
|
|
67
|
+
message.subject = "" unless message.subject
|
|
68
|
+
custom_subject = SanitizeEmail::MailHeaderTools.custom_subject(message)
|
|
69
|
+
message.subject = custom_subject + message.subject
|
|
62
70
|
end
|
|
63
|
-
end
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
end
|
|
72
|
+
# According to https://github.com/mikel/mail
|
|
73
|
+
# this is the correct way to update headers.
|
|
74
|
+
def update_header(header_key, header_value, message)
|
|
75
|
+
return unless header_value
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
num = index + 1
|
|
78
|
-
new_header_key = (num > 1) ? "#{header_key}-#{num}" : header_key
|
|
79
|
-
message.header[new_header_key] = elem.to_s
|
|
77
|
+
# For each address, as header_value can be an array of addresses
|
|
78
|
+
Array(header_value).each_with_index do |elem, index|
|
|
79
|
+
num = index + 1
|
|
80
|
+
new_header_key = (num > 1) ? "#{header_key}-#{num}" : header_key
|
|
81
|
+
message.header[new_header_key] = elem.to_s
|
|
82
|
+
end
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
85
|
end
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# Note: the RspecMatchers are composed matchers:
|
|
6
6
|
# See: http://www.relishapp.com/rspec/rspec-expectations/v/3-5/docs/composing-matchers
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
require_relative "mail_ext"
|
|
9
9
|
|
|
10
10
|
module SanitizeEmail
|
|
11
11
|
# Provides matchers that can be used in
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2008 - 2018, 2020, 2022, 2024 Peter H. Boling of RailsBling.com
|
|
4
|
-
# Released under the MIT license
|
|
5
|
-
|
|
6
3
|
module SanitizeEmail
|
|
7
4
|
module Version
|
|
8
|
-
VERSION = "2.0.
|
|
5
|
+
VERSION = "2.0.11"
|
|
9
6
|
end
|
|
7
|
+
VERSION = Version::VERSION # Traditional Constant Location
|
|
10
8
|
end
|
data/lib/sanitize_email.rb
CHANGED
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
require "version_gem"
|
|
8
8
|
|
|
9
9
|
# This Library
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
require_relative "sanitize_email/version"
|
|
11
|
+
require_relative "sanitize_email/deprecation"
|
|
12
|
+
require_relative "sanitize_email/config"
|
|
13
|
+
require_relative "sanitize_email/mail_header_tools"
|
|
14
|
+
require_relative "sanitize_email/overridden_addresses"
|
|
15
|
+
require_relative "sanitize_email/bleach"
|
|
16
16
|
|
|
17
17
|
module SanitizeEmail
|
|
18
|
+
FORCE_SANITIZE_MUTEX = Mutex.new
|
|
19
|
+
|
|
18
20
|
# Error is raised when a block parameter is required and not provided to a method
|
|
19
21
|
class MissingBlockParameter < StandardError; end
|
|
20
22
|
|
|
@@ -22,17 +24,18 @@ module SanitizeEmail
|
|
|
22
24
|
# This gem must be loaded **after** Rails in order for the Engine/Railtie to register itself automatically.
|
|
23
25
|
# Otherwise, you'd have to manually require what you need from below.
|
|
24
26
|
# Allow non-rails implementations to use this gem
|
|
27
|
+
# :nocov:
|
|
25
28
|
if defined?(::Rails::VERSION)
|
|
26
29
|
if defined?(::Rails::Engine)
|
|
27
30
|
if ::Rails::VERSION::MAJOR >= 6
|
|
28
31
|
# Rails 6.0+
|
|
29
|
-
|
|
32
|
+
require_relative "sanitize_email/engine_v6"
|
|
30
33
|
else
|
|
31
34
|
# Rails 3.1 to 5.2
|
|
32
|
-
|
|
35
|
+
require_relative "sanitize_email/engine_v5"
|
|
33
36
|
end
|
|
34
37
|
elsif ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR.zero?
|
|
35
|
-
|
|
38
|
+
require_relative "sanitize_email/railtie"
|
|
36
39
|
else
|
|
37
40
|
raise "Please use the 0.X.X versions of sanitize_email for Rails 2.X and below."
|
|
38
41
|
end
|
|
@@ -50,11 +53,18 @@ module SanitizeEmail
|
|
|
50
53
|
warn "SanitizeEmail was unable to detect a compatible Mail class to register an interceptor on."
|
|
51
54
|
end
|
|
52
55
|
end
|
|
56
|
+
# :nocov:
|
|
53
57
|
|
|
54
58
|
class << self
|
|
55
59
|
extend SanitizeEmail::Deprecation
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
def force_sanitize
|
|
62
|
+
FORCE_SANITIZE_MUTEX.synchronize { @force_sanitize }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def force_sanitize=(value)
|
|
66
|
+
FORCE_SANITIZE_MUTEX.synchronize { @force_sanitize = value }
|
|
67
|
+
end
|
|
58
68
|
|
|
59
69
|
def [](key)
|
|
60
70
|
return unless key.respond_to?(:to_sym)
|
data.tar.gz.sig
CHANGED
|
Binary file
|