mail_auto_link_obfuscation 0.2.1 → 0.2.2

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: 0fa45b4ff116ad650003acbbfe9ef3396965d2cf
4
- data.tar.gz: 95570b9ced521ebcd48ed129c71ef8a47f6b3d91
3
+ metadata.gz: 28a9071ecdfcf24935c3d0ff1ebaf9064292b6f8
4
+ data.tar.gz: a996da142b119f5a8dfbe1ac6c91fe84d537bf1b
5
5
  SHA512:
6
- metadata.gz: 053a37c48d93dba7395ae5f52e8214288b1bc35ed146e63a687ee227222312a11897fcffa0a792894d60fcf0c59994e17c2b5c92e6390e817fb7a2b33309858c
7
- data.tar.gz: aa692657c059d83f4614d4c6d76a7992bde42fa052f4aeeb9378d4e4423cd729bfdddd92be58a4e740753b21258f934d5da831e4641fbd1dd550442efb679525
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 = /\S+@\w+(?:\.\w+)+/
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(&:content).to_set
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.body.decoded)
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.body.decoded)
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.body.decoded)
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.body.decoded)
68
+ @mail.text_part.body = transform_text(@mail.text_part.decoded)
69
69
  end
70
70
 
71
71
  def transform_text(text)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MailAutoLinkObfuscation
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  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.1
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-01-23 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties