File tree 3 files changed +27
-14
lines changed
3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,11 @@ def surround_urls_with_a_tag(text, urls)
128
128
result + h ( text )
129
129
end
130
130
131
+ def spam? ( mail )
132
+ spam = [ *mail . header [ 'X-Spam' ] ]
133
+ spam . any? { |v | v . value . upcase == 'YES' }
134
+ end
135
+
131
136
def virus_detected? ( mail )
132
137
virus = [ *mail . header [ 'X-Virus' ] ]
133
138
return if virus . empty?
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ div.footer{
52
52
padding : 2pt ;
53
53
}
54
54
55
- .mail-virus {
55
+ .mail-alert {
56
56
background-color : # dc3545 ;
57
57
color : # ffffff ;
58
58
}
Original file line number Diff line number Diff line change 3
3
mail <%= h ( mailnum ) %> was not found.
4
4
<% else %>
5
5
<% if virus = virus_detected? ( mail ) %>
6
- < div class ='mail-virus '>
7
- このメールにはウイルスが検出されています: <%= h ( virus ) %>
8
- </ div >
6
+ < div class ='mail-virus mail-alert '> このメールにはウイルスが検出されています: <%= h ( virus ) %> </ div >
7
+ <% end %>
8
+ <% if spam = spam? ( mail ) %>
9
+ < div class ='mail-spam mail-alert '> このメールはスパムメールと判定されています</ div >
9
10
<% end %>
10
11
< div class ='mail-actions '>
11
12
<% if remote_user %>
20
21
</ div >
21
22
< pre > <%= h ( get_header mail ) %> </ pre >
22
23
< hr >
23
- < pre > <%= render_mail_body ( mail ) %> </ pre >
24
+ < pre class =' mail-body ' > <%= render_mail_body ( mail ) %> </ pre >
24
25
<% if !mail . attachments . empty? %>
25
26
< hr >
26
27
< pre > 添付ファイル:</ pre >
32
33
</ a > </ li >
33
34
<% end %>
34
35
</ ul >
35
- <% if virus %>
36
- < script >
37
- for ( const link of document . querySelectorAll ( '.mail-attachments a' ) ) {
38
- link . addEventListener ( 'click' , function ( e ) {
39
- if ( ! confirm ( 'この添付ファイルは危険な可能性があります。本当にダウンロードしますか?' ) ) e . preventDefault ( ) ;
40
- } )
41
- }
42
- </ script >
43
- <% end %>
36
+ <% end %>
37
+
38
+ <% if virus || spam %>
39
+ < script >
40
+ for ( const link of document . querySelectorAll ( '.mail-body a' ) ) {
41
+ link . addEventListener ( 'click' , function ( e ) {
42
+ if ( ! confirm ( 'このリンクは危険な可能性があります。本当に開きますか?' ) ) e . preventDefault ( ) ;
43
+ } )
44
+ }
45
+
46
+ for ( const link of document . querySelectorAll ( '.mail-attachments a' ) ) {
47
+ link . addEventListener ( 'click' , function ( e ) {
48
+ if ( ! confirm ( 'この添付ファイルは危険な可能性があります。本当にダウンロードしますか?' ) ) e . preventDefault ( ) ;
49
+ } )
50
+ }
51
+ </ script >
44
52
<% end %>
45
53
<% end %>
46
54
</ div >
You can’t perform that action at this time.
0 commit comments