eml_to_pdf_ext 0.5.5 → 0.5.6

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: 4efc8ac44ee7565c20e95f011a02e6a10f14cb35
4
- data.tar.gz: 4b2184057931a6d83a0c8d2b9de4fc78687b4a1a
3
+ metadata.gz: 992328b3cdfaa1ee5bf54e93689a225ebb46bc40
4
+ data.tar.gz: 7924a707e8ed56dd358192fcd708a06eeae9c72b
5
5
  SHA512:
6
- metadata.gz: 65ca04591d654ea0d3fb88b0e04f30ebb89c070c0db35f337b65949d96f1404f83e6a4126e7c0e4c90672d5dff6d5cd69e08d691765ec6c1e2216c8bd998241d
7
- data.tar.gz: 3cb143843737de97669bb2f7c7dbebec5e9eab1b3025cbe796debe5a77a945304586742d466c4680c99573c543c4f427d75148fb127d8f2e46b02ae9871ef982
6
+ metadata.gz: 9f374e0e6541303ae2225613454296327614df9a635d2945844bbf3f26108403df6fb59e1f6a560d66806a1d050035ffc779904e1250e95ef6f6b23fbb50fe16
7
+ data.tar.gz: dc57489286f9fa98063fc146ee80cf329034051fa654e121cc642aeea2a0f7e440f53cdfa6e037bd79e67552d1b9396f534dff5e722e5a1253edaa9d9806b2b0
@@ -1,12 +1,13 @@
1
1
  module EmlToPdf
2
2
  class Configuration
3
- attr_accessor :from_label, :to_label, :cc_label, :date_label, :metadata_visible, :links_enabled
3
+ attr_accessor :from_label, :to_label, :cc_label, :date_label, :metadata_visible, :links_enabled, :link_format_whitelist
4
4
 
5
5
  def initialize
6
6
  @from_label, @to_label, @cc_label, @date_label= 'From', 'To', 'Cc', 'Date'
7
7
  @date_format = lambda { |date| date.strftime('%Y-%m-%d %H:%M:%S %z') }
8
8
  @metadata_visible = true
9
9
  @links_enabled = true
10
+ @link_format_whitelist = []
10
11
  end
11
12
 
12
13
  def date_format(&block)
@@ -15,7 +15,7 @@ module EmlToPdf
15
15
  extraction = extraction.next until extraction.finished?
16
16
  html = extraction.to_html
17
17
  html = resolve_cids_from_attachments(html, @mail.all_parts)
18
- html = disable_links(html) if links_disabled?
18
+ html = disable_links(html) unless links_enabled?
19
19
  html = add_mail_metadata_to_html(@mail, html) if display_metadata?
20
20
  html
21
21
  end
@@ -78,7 +78,11 @@ module EmlToPdf
78
78
 
79
79
  def disable_links(html)
80
80
  doc = Nokogiri::HTML(html)
81
- doc.css('a').each { |x| x['target'] = '_blank' }
81
+ doc.css('a').reject do |x|
82
+ allowed_formats.any? { |format| x['href'].start_with?(format) }
83
+ end.each do |x|
84
+ x['target'] = '_blank'
85
+ end
82
86
  doc.to_html
83
87
  end
84
88
 
@@ -86,8 +90,12 @@ module EmlToPdf
86
90
  EmlToPdf.configuration.metadata_visible
87
91
  end
88
92
 
89
- def links_disabled?
90
- !EmlToPdf.configuration.links_enabled
93
+ def links_enabled?
94
+ EmlToPdf.configuration.links_enabled
95
+ end
96
+
97
+ def allowed_formats
98
+ EmlToPdf.configuration.link_format_whitelist
91
99
  end
92
100
  end
93
101
  end
@@ -1,3 +1,3 @@
1
1
  module EmlToPdf
2
- VERSION = '0.5.5'
2
+ VERSION = '0.5.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eml_to_pdf_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Siegrist