eml_to_pdf_ext 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eml_to_pdf/configuration.rb +2 -1
- data/lib/eml_to_pdf/email.rb +12 -4
- data/lib/eml_to_pdf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 992328b3cdfaa1ee5bf54e93689a225ebb46bc40
|
4
|
+
data.tar.gz: 7924a707e8ed56dd358192fcd708a06eeae9c72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/eml_to_pdf/email.rb
CHANGED
@@ -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)
|
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').
|
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
|
90
|
-
|
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
|
data/lib/eml_to_pdf/version.rb
CHANGED