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: a0a7d093d20dde86b5e94612905a3449c5916c0f
4
- data.tar.gz: fe3d113442d492eb36a1c71984beba1b4da57630
3
+ metadata.gz: b9de6df0b8e7d35683ed12234f440964bd161911
4
+ data.tar.gz: 61449ceb65e0a36ab81f5ef2079f0937c91316d2
5
5
  SHA512:
6
- metadata.gz: e350cea21dcb344414af7829fc2c05e3100b523931f8bec6383f2a66ce1bc7deb86b1a51431523f879506cd931e10fa542a90c8371df280dd27cecac44d226fb
7
- data.tar.gz: e2cab258d92ce3c939f27f03f58bf1a95af6f7b0c4268c70195b3daa06b6549997418e83e708ede66e6b5542602ed614bafd0e19b4b47bcaefabda3aa14282c8
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(/^mailto:/, '') }.to_set
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailAutoLinkObfuscation
4
- VERSION = '0.2.5'
4
+ VERSION = '0.2.6'
5
5
  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.5
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: 2017-12-28 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail