mail_auto_link_obfuscation 0.2.1 → 0.2.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a9071ecdfcf24935c3d0ff1ebaf9064292b6f8
|
4
|
+
data.tar.gz: a996da142b119f5a8dfbe1ac6c91fe84d537bf1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3746fb5ce3038de84cadfdcb12cc619ce0ba2561b31479284736065f6fe421cb6163f772508674df174580affd54e35a1798ef3591123f253cfed8cb78176f54
|
7
|
+
data.tar.gz: dfc960e352938019b00c7b35e763c9f1d68191f2b96cacbafb82444b891f8f1498b19043bdce9eb2cec3fef6730595bc60ddbeffd86ae5d4831ccf14246725b7
|
@@ -3,7 +3,7 @@ require 'nokogiri'
|
|
3
3
|
|
4
4
|
module MailAutoLinkObfuscation
|
5
5
|
class AutoLinkObfuscator
|
6
|
-
AUTO_LINKED_EMAIL_PATTERN =
|
6
|
+
AUTO_LINKED_EMAIL_PATTERN = /[\w\.%+-]+@\w+(?:\.\w+)+/
|
7
7
|
AUTO_LINKED_URL_PATTERN = %r{((\w+:)?//\w+(\.\w+)*|\w+(\.\w+)*\.\w{2,})\S*}
|
8
8
|
AUTO_LINKED_PATTERN = Regexp.new([AUTO_LINKED_EMAIL_PATTERN, AUTO_LINKED_URL_PATTERN].join('|'))
|
9
9
|
KEY_CHARS = %r{[@.:/]+}
|
@@ -30,17 +30,17 @@ module MailAutoLinkObfuscation
|
|
30
30
|
|
31
31
|
def extract_link_whitelist_from(doc)
|
32
32
|
return Set.new unless doc
|
33
|
-
doc.xpath('//@href').map(
|
33
|
+
doc.xpath('//@href').map { |href| href.content.sub(/^mailto:/, '') }.to_set
|
34
34
|
end
|
35
35
|
|
36
36
|
def html_body_doc
|
37
37
|
return unless @mail.content_type.include? 'text/html'
|
38
|
-
@html_body_doc ||= Nokogiri::HTML(@mail.
|
38
|
+
@html_body_doc ||= Nokogiri::HTML(@mail.decoded)
|
39
39
|
end
|
40
40
|
|
41
41
|
def html_part_doc
|
42
42
|
return unless @mail.html_part
|
43
|
-
@html_part_doc ||= Nokogiri::HTML(@mail.html_part.
|
43
|
+
@html_part_doc ||= Nokogiri::HTML(@mail.html_part.decoded)
|
44
44
|
end
|
45
45
|
|
46
46
|
def transform_html_body
|
@@ -61,11 +61,11 @@ module MailAutoLinkObfuscation
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def transform_text_body
|
64
|
-
@mail.body = transform_text(@mail.
|
64
|
+
@mail.body = transform_text(@mail.decoded)
|
65
65
|
end
|
66
66
|
|
67
67
|
def transform_text_part
|
68
|
-
@mail.text_part.body = transform_text(@mail.text_part.
|
68
|
+
@mail.text_part.body = transform_text(@mail.text_part.decoded)
|
69
69
|
end
|
70
70
|
|
71
71
|
def transform_text(text)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_auto_link_obfuscation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Jundt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|