Skip to content

Commit

Permalink
w2: do no allow remote images in encrypted messages unless configured…
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Jun 25, 2018
1 parent 295d73d commit dc1b680
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -5,6 +5,7 @@
* Toggle between parts without re-opening
* Configure default part
* Show HTML parts if no other part (configurable)
* Do not allow images in encrypted messages (#499)
* Zoom messages with C-+ and C--

== v0.12
Expand Down
4 changes: 3 additions & 1 deletion src/config.cc
Expand Up @@ -228,7 +228,7 @@ namespace Astroid {

/* attachments
*
* a chunk is saved and opened with the this command */
* a chunk is saved and opened with this command */
default_config.put ("attachment.external_open_cmd", "xdg-open");

/* thread view
Expand All @@ -240,6 +240,8 @@ namespace Astroid {
default_config.put ("thread_view.preferred_type", "plain");
default_config.put ("thread_view.preferred_html_only", false);

default_config.put ("thread_view.allow_remote_when_encrypted", false);

/* if a link is clicked (html, ftp, etc..) it is executed with this
* command. */
default_config.put ("thread_view.open_external_link", "xdg-open");
Expand Down
21 changes: 18 additions & 3 deletions src/modes/thread_view/thread_view.cc
Expand Up @@ -110,7 +110,7 @@ namespace Astroid {
"enable-javascript", FALSE,
"enable-java", FALSE,
"enable-plugins", FALSE,
"auto-load-images", TRUE,
"auto-load-images", FALSE,
"enable-dns-prefetching", FALSE,
"enable-fullscreen", FALSE,
"enable-html5-database", FALSE,
Expand Down Expand Up @@ -280,6 +280,8 @@ namespace Astroid {
const gchar * uri_c = webkit_uri_request_get_uri (request);
ustring uri (uri_c);

LOG (debug) << "tv: request for resource: " << uri;

// prefix of local uris for loading image thumbnails
vector<ustring> allowed_uris =
{
Expand Down Expand Up @@ -942,8 +944,21 @@ namespace Astroid {
});

keys.register_key ("C-i", "thread_view.show_remote_images",
"Show remote images (warning: approves all requests to remote content!)",
[&] (Key) {
"Show remote images (warning: approves all requests to remote content for this thread!)",
[&] (Key) {
/* we only allow remote images / resources when
* no encrypted parts are present */
if (!config.get<bool> ("allow_remote_when_encrypted")) {
for (auto &m : mthread->messages) {
for (auto &c : mthread->all_parts()) {
if (c->isencrypted) {
LOG (error) "tv: remote resources are not allowed in encrypted messages. check your configuration if you wish to change this.";
return true;
}
}
}
}

show_remote_images = true;
LOG (debug) << "tv: show remote images: " << show_remote_images;
reload_images ();
Expand Down

0 comments on commit dc1b680

Please sign in to comment.