Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions config/prefs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,17 @@
},
];

$_prefs['image_replacement'] = [
'value' => 1,
'type' => 'checkbox',
'desc' => _("Block images in messages unless they are specifically requested to be loaded?"),
$_prefs['image_replacement'] = array(
'value' => 2,
'type' => 'enum',
'enum' => array(
0 => _("Show all images"),
1 => _("Block all images in messages unless they are specifically requested to be loaded?"),
2 => _("Show inline images, block remote images"),
),
'desc' => _("How should images in HTML messages be handled?"),
'help' => 'prefs-image_replacement',
];
);

$_prefs['image_replacement_manage'] = [
'type' => 'special',
Expand Down
30 changes: 27 additions & 3 deletions lib/Mime/Viewer/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ protected function _IMPrender($inline)
'imgblock' => false,
'imgbroken' => false,
'inline' => $inline,
'remoteblock' => false,
'style' => [],
];
}
Expand Down Expand Up @@ -231,8 +232,13 @@ protected function _IMPrender($inline)

$link = $text = null;
if ($this->_imptmp['imgblock']) {
$text = _('Images have been blocked in this message part.');
$link = _('Show Images?');
if ($this->_imptmp['remoteblock']) {
$text = _('Remote images have been blocked in this message part.');
$link = _('Load Remote Images?');
} else {
$text = _('Images have been blocked in this message part.');
$link = _('Show Images?');
}
} elseif ($this->_imptmp['cssblock']) {
$text = _('Message styling has been suppressed in this message part since the style data lives on a remote server.');
$link = _('Load Styling?');
Expand Down Expand Up @@ -372,6 +378,7 @@ protected function _node($doc, $node)
$val = $node->getAttribute('src');

/* Multipart/related. */
$is_cid = false;
if (($tag == 'img') && ($id = $this->_cidSearch($val))) {
$val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', ['params' => [
'ctype' => 'image/*',
Expand All @@ -381,7 +388,7 @@ protected function _node($doc, $node)
}

/* Block images.*/
if ($this->_imgBlock()) {
if ($this->_imgBlock() && !($is_cid && $this->_isRemoteBlock())) {
if (Horde_Url_Data::isData($val)) {
$url = new Horde_Url_Data($val);
} else {
Expand All @@ -401,6 +408,9 @@ protected function _node($doc, $node)
$node->setAttribute(self::IMGBLOCK, $url);
$node->setAttribute('src', $this->_imgBlockImg());
$this->_imptmp['imgblock'] = true;
if ($this->_isRemoteBlock()) {
$this->_imptmp['remoteblock'] = true;
}
} else {
$node->parentNode->removeChild($node);
$this->_imptmp['imgbroken'] = true;
Expand Down Expand Up @@ -636,6 +646,9 @@ protected function _styleCallback($matches)
} else {
$this->_imptmp['node']->setAttribute(self::IMGBLOCK, $matches[2]);
$this->_imptmp['imgblock'] = true;
if ($this->_isRemoteBlock()) {
$this->_imptmp['remoteblock'] = true;
}
$replace = $this->_imgBlockImg();
}
return $matches[1] . $replace . $matches[3];
Expand Down Expand Up @@ -700,4 +713,15 @@ protected function _imgBlockImg()
return $this->_imptmp['blockimg'];
}

/**
* Are we in "block remote images only" mode?
*
* @return boolean True if only remote images are blocked.
*/
protected function _isRemoteBlock()
{
global $prefs;

return ($prefs->getValue('image_replacement') == 2);
}
}
5 changes: 4 additions & 1 deletion locale/en/help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,10 @@
<entry id="prefs-image_replacement">
<title>Message: Preferences: Image Replacement</title>
<para>
For messages displayed inline (i.e. on the message view page), should all image tags be blocked until you specifically decide to view those images? Note that, if explicitly viewing the attachment, images will always be displayed.
For messages displayed inline (i.e. on the message view page), controls how images embedded in HTML messages are handled: show all images (including remote ones, which may be used by senders to track whether you have read a message); show only images attached directly to the message while blocking those loaded from remote servers (recommended); or block all images until you specifically decide to view them.
</para>
<para>
In all blocking modes, a notification appears allowing you to unblock images on a per-message basis, or to permanently allow images from a given sender. Note that, if explicitly viewing the attachment, images will always be displayed.
</para>
</entry>

Expand Down
Loading