mail_auto_link_obfuscation 0.1.1 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d193dd872e293539f5bff5e25c87475e985438
|
4
|
+
data.tar.gz: 6b0725389bd2f78c87f43c18f951adb39ba16663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24594ba61270faebcf5d82b1d454c83b6081b9ecc044985c3a9fcd4b136d0a403a6da95527466d58cb291d0dc1c717d25a5c77578e94c315872c0dec4b5734c
|
7
|
+
data.tar.gz: 18f9362dc44978733eb4b22268477dfefd7b3d6ce73fc20b35e3158f5bc30b3dea7e89b8e1c2fa4b0c75aab4cf1d498d132a024861f94d7fb471333357de64b9
|
data/README.md
CHANGED
@@ -4,10 +4,9 @@ This gem hooks up your Rails application and prevents email clients from automat
|
|
4
4
|
|
5
5
|
Automatic links can be an undesired feature, especially when user generated content is part of your emails, e.g. a user's name. If your user is called `your.enemy.com` and you insert his name directly in your mail, you will find that most email clients will make this name clickable. This effect can brake your email layout/design and even worse, it can be considered a security issue.
|
6
6
|
|
7
|
-
To prevent email clients from auto-linking any link-like text we have to outsmart their link parsers.
|
7
|
+
To prevent email clients from auto-linking any link-like text we have to outsmart their link parsers. Wrapping special link characters like `.`, `/` and `@` with invisible/non-printable [zero-width non-joiner](https://en.wikipedia.org/wiki/Zero-width_non-joiner) characters (Unicode U+200C) has shown to work for most email clients.
|
8
8
|
|
9
|
-
|
10
|
-
Plain text example: `Hello your.enemy.com!` becomes `Hello your .enemy .com`
|
9
|
+
Example: `"Hello your.enemy.com!"` becomes `"Hello your\u200C.\u200Cenemy\u200C.\u200Ccom"`
|
11
10
|
|
12
11
|
Note that this module will not touch any explicit links mentioned in anchors in the `href` attribute. Those links are considered desired and trusted. If you provide HTML and text parts with your email (which you should) this gem is also smart enough not to change links in the text part if those have been explicitly hyperlinked in the HTML part.
|
13
12
|
|
@@ -28,14 +27,6 @@ class MyMailer
|
|
28
27
|
end
|
29
28
|
```
|
30
29
|
|
31
|
-
## Configuration
|
32
|
-
The obfuscation process can be configured at two places:
|
33
|
-
|
34
|
-
1. `Rails.application.config.mail_auto_link_obfuscation`
|
35
|
-
2. `MyMailer#mail_auto_link_obfuscation_options`
|
36
|
-
|
37
|
-
Options are passed as a hash. At this moment you can only add a `style` attribute to the inserted `span` tags using `{ span_style: "font:inherit" }`
|
38
|
-
|
39
30
|
## Development
|
40
31
|
|
41
32
|
Specs can be run with `rake spec`. Guard is also available.
|
@@ -53,21 +53,13 @@ module MailAutoLinkObfuscation
|
|
53
53
|
|
54
54
|
def transform_html(doc)
|
55
55
|
doc.xpath('//body/descendant::text()').each do |node|
|
56
|
-
|
57
|
-
|
58
|
-
match.gsub(KEY_CHARS, span_template)
|
59
|
-
end
|
60
|
-
|
61
|
-
node.replace(content)
|
56
|
+
text = CGI.escapeHTML(node.content)
|
57
|
+
node.replace(transform_text(text))
|
62
58
|
end
|
63
59
|
|
64
60
|
doc.to_s
|
65
61
|
end
|
66
62
|
|
67
|
-
def span_template
|
68
|
-
@span_template ||= '<span' + (@options[:span_style] ? " style=#{@options[:span_style]}" : '') + '>\0</span>'
|
69
|
-
end
|
70
|
-
|
71
63
|
def transform_text_body
|
72
64
|
@mail.body = transform_text(@mail.body.decoded)
|
73
65
|
end
|
@@ -78,7 +70,7 @@ module MailAutoLinkObfuscation
|
|
78
70
|
|
79
71
|
def transform_text(text)
|
80
72
|
transform_auto_linked_pattern(text) do |match|
|
81
|
-
match.gsub(KEY_CHARS,
|
73
|
+
match.gsub(KEY_CHARS, "\u200C\\0\u200C")
|
82
74
|
end
|
83
75
|
end
|
84
76
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'Obfuscate link-like mail content on delivery to prevent auto hyperlinks in modern email clients.'
|
14
14
|
spec.description = 'Obfuscate link-like mail content on delivery to prevent auto hyperlinks in modern email clients.'
|
15
|
-
spec.homepage = ''
|
15
|
+
spec.homepage = 'https://github.com/moneybird/mail_auto_link_obfuscation'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_auto_link_obfuscation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Jundt
|
@@ -199,7 +199,7 @@ files:
|
|
199
199
|
- lib/mail_auto_link_obfuscation/railtie.rb
|
200
200
|
- lib/mail_auto_link_obfuscation/version.rb
|
201
201
|
- mail_auto_link_obfuscation.gemspec
|
202
|
-
homepage:
|
202
|
+
homepage: https://github.com/moneybird/mail_auto_link_obfuscation
|
203
203
|
licenses:
|
204
204
|
- MIT
|
205
205
|
metadata: {}
|