Skip to content

Commit e51fd27

Browse files
authored
Merge pull request #5 from williamdes/improvements
Minor project improvements
2 parents f2be525 + 2b449df commit e51fd27

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.gitignore export-ignore
2+
.gitattributes export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor
2+
/composer.lock

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
Displays a small icon after the subject line that displays the (presumed) encryption state of received mails.
44
This plugin parses the "Received" header for the last hop and checks if TLS was used. This requires TLS logging in the receiving MTA.
55

6-
In Postfix this can be enabled by setting `smtpd_tls_received_header = yes`. The regex used to parse the header has only been tested against Postfix.
6+
In Postfix this can be enabled by setting [`smtpd_tls_received_header = yes`](https://www.postfix.org/postconf.5.html#smtpd_tls_received_header). The regex used to parse the header has only been tested against Postfix.
77

88
Note that while this talks about "encryption", this does not imply security. An encrypted mail may still be insecure, mostly because mailservers generally use "opportunistic TLS", where MITM attacks are possible.
99
This also only validates the last hop of an email - some emails may run through multiple hops and we don't know anything about the security of these.
1010

11-
Inspired by https://github.com/SS88UK/roundcube-easy-unsubscribe
11+
Inspired by [roundcube-easy-unsubscribe](https://github.com/SS88UK/roundcube-easy-unsubscribe)
1212

13-
![Example screenshot](tls_icon_example.png)
13+
![Example screenshot](tls_icon_example.png)
14+
15+
## Installation
16+
17+
The [composer library](https://packagist.org/packages/germancoding/tls_icon) name is: `germancoding/tls_icon`.
18+
19+
The plugin name to add to your config file is: `tls_icon`.

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@
1313
],
1414
"require": {
1515
"roundcube/plugin-installer": ">=0.1.6"
16+
},
17+
"config": {
18+
"allow-plugins": {
19+
"roundcube/plugin-installer": true
20+
}
1621
}
17-
}
22+
}

localization/fr_FR.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$labels = array();
4+
5+
$labels['internal'] = 'Cet e-mail est interne';
6+
$labels['unencrypted'] = 'E-mail reçu via une connexion non chiffrée !';

tls_icon.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
class tls_icon extends rcube_plugin
4-
{
4+
{
55
private $message_headers_done = false;
66
private $icon_img;
77
private $rcmail;
@@ -13,12 +13,12 @@ function init()
1313

1414
$this->add_hook('message_headers_output', array($this, 'message_headers'));
1515
$this->add_hook('storage_init', array($this, 'storage_init'));
16-
16+
1717
$this->include_stylesheet('tls_icon.css');
1818

1919
$this->add_texts('localization/');
2020
}
21-
21+
2222
function get_received_header_content($Received_Header)
2323
{
2424
$Received = null;
@@ -41,7 +41,7 @@ public function storage_init($p)
4141
$p['fetch_headers'] = trim(($p['fetch_headers']?? '') . ' ' . strtoupper('Received'));
4242
return $p;
4343
}
44-
44+
4545
public function message_headers($p)
4646
{
4747
if($this->message_headers_done===false)
@@ -50,12 +50,12 @@ public function message_headers($p)
5050

5151
$Received_Header = $p['headers']->others['received'] ?? null;
5252
$Received = $this->get_received_header_content($Received_Header);
53-
53+
5454
if($Received == null) {
5555
// There was no Received Header. Possibly an outbound mail. Do nothing.
5656
return $p;
5757
}
58-
58+
5959
if ( preg_match_all('/\(using TLS.*.*\) \(/im', $Received, $items, PREG_PATTERN_ORDER) ) {
6060
$data = $items[0][0];
6161

@@ -66,11 +66,11 @@ public function message_headers($p)
6666
$needle = ") (";
6767
$pos = strrpos($data, $needle);
6868
$data = substr_replace($data, "", $pos, strlen($needle));
69-
69+
7070
$this->icon_img .= '<img class="lock_icon" src="plugins/tls_icon/lock.svg" title="'. htmlentities($data) .'" />';
7171
} else if(preg_match_all('/\([a-zA-Z]*, from userid [0-9]*\)/im', $Received, $items, PREG_PATTERN_ORDER)){
7272
$this->icon_img .= '<img class="lock_icon" src="plugins/tls_icon/blue_lock.svg" title="' . $this->gettext('internal') . '" />';
73-
}
73+
}
7474
else {
7575
// TODO: Mails received from localhost but without TLS are currently flagged insecure
7676
$this->icon_img .= '<img class="lock_icon" src="plugins/tls_icon/unlock.svg" title="' . $this->gettext('unencrypted') . '" />';

0 commit comments

Comments
 (0)