From f8ca8d1b63a1f3b89671f8e1dfa87bad4b60312e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 23 May 2019 10:34:39 +0200 Subject: [PATCH] Fix invalid path to "add contact" icon when using assets_path setting This and a few other icons --- CHANGELOG | 1 + program/include/rcmail_output_html.php | 11 ++++++++++- program/steps/addressbook/func.inc | 10 +++++++--- program/steps/mail/compose.inc | 8 ++++---- program/steps/mail/func.inc | 4 ++-- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 12ea157ca..e3dd337d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,6 +29,7 @@ CHANGELOG Roundcube Webmail - Enigma: Fix bug where revoked users/keys were not greyed out in key info - Enigma: Fix error message when trying to encrypt with a revoked key (#6607) - Enigma: Fix "decryption oracle" bug [CVE-2019-10740] (#6638) +- Fix invalid path to "add contact" icon when using assets_path setting - Fix invalid path to blocked.gif when using assets_path setting (#6752) - Fix so advanced search dialog is not automatically displayed on searchonly addressbooks (#6679) - Fix so an error is logged when more than one attachment plugin has been enabled, initialize the first one (#6735) diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index f2499d7ca..2aca0c378 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -872,12 +872,21 @@ EOF; /** * Modify path by adding URL prefix if configured + * + * @param string $path Asset path + * @param bool $abs_url Pass to self::abs_url() first + * + * @return string Asset path */ - public function asset_url($path) + public function asset_url($path, $abs_url = false) { // iframe content can't be in a different domain // @TODO: check if assests are on a different domain + if ($abs_url) { + $path = $this->abs_url($path, true); + } + if (!$this->assets_path || in_array($path[0], array('?', '/', '.')) || strpos($path, '://')) { return $path; } diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 3e4ce4d9f..44d3115d0 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -910,12 +910,16 @@ function rcmail_contact_photo($attrib) { global $SOURCE_ID, $CONTACTS, $CONTACT_COLTYPES, $RCMAIL; - if ($result = $CONTACTS->get_result()) + if ($result = $CONTACTS->get_result()) { $record = $result->first(); + } - $photo_img = $attrib['placeholder'] ? $RCMAIL->output->abs_url($attrib['placeholder'], true) : 'program/resources/blank.gif'; - if ($record['_type'] == 'group' && $attrib['placeholdergroup']) + if ($record['_type'] == 'group' && $attrib['placeholdergroup']) { $photo_img = $RCMAIL->output->abs_url($attrib['placeholdergroup'], true); + } + else { + $photo_img = $attrib['placeholder'] ? $RCMAIL->output->abs_url($attrib['placeholder'], true) : 'program/resources/blank.gif'; + } $RCMAIL->output->set_env('photo_placeholder', $RCMAIL->output->asset_url($photo_img)); diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 92bfd998a..08bce3bce 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -1208,7 +1208,7 @@ function rcmail_compose_attachment_list($attrib) if (is_array($COMPOSE['attachments'])) { if ($attrib['deleteicon']) { $button = html::img(array( - 'src' => $RCMAIL->output->abs_url($attrib['deleteicon'], true), + 'src' => $RCMAIL->output->asset_url($attrib['deleteicon'], true), 'alt' => $RCMAIL->gettext('delete') )); } @@ -1255,13 +1255,13 @@ function rcmail_compose_attachment_list($attrib) } if ($attrib['deleteicon']) - $COMPOSE['deleteicon'] = $RCMAIL->output->abs_url($attrib['deleteicon'], true); + $COMPOSE['deleteicon'] = $RCMAIL->output->asset_url($attrib['deleteicon'], true); else if (rcube_utils::get_boolean($attrib['textbuttons'])) $COMPOSE['textbuttons'] = true; if ($attrib['cancelicon']) - $OUTPUT->set_env('cancelicon', $RCMAIL->output->abs_url($attrib['cancelicon'], true)); + $OUTPUT->set_env('cancelicon', $RCMAIL->output->asset_url($attrib['cancelicon'], true)); if ($attrib['loadingicon']) - $OUTPUT->set_env('loadingicon', $RCMAIL->output->abs_url($attrib['loadingicon'], true)); + $OUTPUT->set_env('loadingicon', $RCMAIL->output->asset_url($attrib['loadingicon'], true)); $OUTPUT->set_env('attachments', $jslist); $OUTPUT->add_gui_object('attachmentlist', $attrib['id']); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 8ee4d78c4..26e4a2dd6 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -664,7 +664,7 @@ function rcmail_options_menu_link($attrib = array()) $inner = $title = $RCMAIL->gettext($attrib['label'] ?: 'listoptions'); if (is_string($attrib['optionsmenuicon']) && $attrib['optionsmenuicon'] != 'true') { - $inner = html::img(array('src' => $RCMAIL->output->abs_url($attrib['optionsmenuicon'], true), 'alt' => $title)); + $inner = html::img(array('src' => $RCMAIL->output->asset_url($attrib['optionsmenuicon'], true), 'alt' => $title)); } else if ($attrib['innerclass']) { $inner = html::span($attrib['innerclass'], $inner); @@ -1335,7 +1335,7 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null, if ($addicon && $_SESSION['writeable_abook']) { $label = $RCMAIL->gettext('addtoaddressbook'); $icon = html::img(array( - 'src' => $RCMAIL->output->abs_url($addicon, true), + 'src' => $RCMAIL->output->asset_url($addicon, true), 'alt' => $label, 'class' => 'noselect', ));