mail_auto_link_obfuscation 0.2.5 → 0.2.6
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: b9de6df0b8e7d35683ed12234f440964bd161911
|
4
|
+
data.tar.gz: 61449ceb65e0a36ab81f5ef2079f0937c91316d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85943c2925b95874753c9b6de549f1f83f4f9f2273fb68b3c96b2422c2e9645e3070cb17537369f23ee018956d8630657eea79f638b1c910a954083132fe8d02
|
7
|
+
data.tar.gz: 7f2dca01f6ed72576f86fbf134248cea6456b6f9f1b00ae1f0d25f712cb9333544e2b3b8aeb309aba23f4dd149c89766df49192ed84685c8c0a54852b0d042b9
|
@@ -7,7 +7,7 @@ module MailAutoLinkObfuscation
|
|
7
7
|
AUTO_LINKED_EMAIL_PATTERN = /[\w\.%+-]+@\w+(?:\.\w+)+/
|
8
8
|
AUTO_LINKED_URL_PATTERN = %r{(?:(?:\w+:)?//\w+(?:\.\w+)*|\w+(?:\.\w+)*\.\w{2,}(?!\.\w+))\S*}
|
9
9
|
AUTO_LINKED_PATTERN = Regexp.new([AUTO_LINKED_EMAIL_PATTERN, AUTO_LINKED_URL_PATTERN].join('|'))
|
10
|
-
KEY_CHARS = %r{[
|
10
|
+
KEY_CHARS = %r{[@.]+|:*//+}
|
11
11
|
|
12
12
|
def initialize(mail, options)
|
13
13
|
@mail = mail
|
@@ -31,7 +31,8 @@ module MailAutoLinkObfuscation
|
|
31
31
|
|
32
32
|
def extract_link_whitelist_from(doc)
|
33
33
|
return Set.new unless doc
|
34
|
-
doc.xpath('//@href').map { |href| href.content.sub(
|
34
|
+
whitelist = doc.xpath('//@href').map { |href| href.content.sub(/\Amailto:/, '') }.to_set
|
35
|
+
whitelist.merge(whitelist.map { |href| href.sub(%r{\A[a-z]+://}, '') })
|
35
36
|
end
|
36
37
|
|
37
38
|
def html_body_doc
|
@@ -54,6 +55,7 @@ module MailAutoLinkObfuscation
|
|
54
55
|
|
55
56
|
def transform_html(doc)
|
56
57
|
doc.xpath('//body/descendant::text()').each do |node|
|
58
|
+
next if node.parent&.name == 'script'
|
57
59
|
text = CGI.escapeHTML(node.content)
|
58
60
|
node.replace(transform_text(text))
|
59
61
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Jundt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|