mail_auto_link_obfuscation 0.1.0 → 0.1.1
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: 947109ff0c3285f1823f922d65078a11c56c16c2
|
4
|
+
data.tar.gz: 1f874335326fbb669fd4893c573b42a8c91c47c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8f9b45d76bd7cf36bb655d314bb95ab99eb83457320e8652e4fd5565bf3235aa69a85009e0a9e5d47d2000a622e94ac692e13ed4dca72ace2495766592e655e
|
7
|
+
data.tar.gz: c0992cd6d573e072ce27455a324810f7fd91090fe17fc39dbfd7b0b344cba7375c9ea5bcf9ffac28c656076e04889e94f77829c32a4674964bdc5082d51303f3
|
@@ -4,9 +4,9 @@ require 'nokogiri'
|
|
4
4
|
module MailAutoLinkObfuscation
|
5
5
|
class AutoLinkObfuscator
|
6
6
|
AUTO_LINKED_EMAIL_PATTERN = /\S+@\w+(?:\.\w+)+/
|
7
|
-
AUTO_LINKED_URL_PATTERN = %r{(\w
|
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
|
-
KEY_CHARS =
|
9
|
+
KEY_CHARS = %r{[@.:/]+}
|
10
10
|
|
11
11
|
def initialize(mail, options)
|
12
12
|
@mail = mail
|
@@ -53,7 +53,8 @@ module MailAutoLinkObfuscation
|
|
53
53
|
|
54
54
|
def transform_html(doc)
|
55
55
|
doc.xpath('//body/descendant::text()').each do |node|
|
56
|
-
content =
|
56
|
+
content = CGI.escapeHTML(node.content)
|
57
|
+
content = transform_auto_linked_pattern(content) do |match|
|
57
58
|
match.gsub(KEY_CHARS, span_template)
|
58
59
|
end
|
59
60
|
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Jundt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|