From 07795ba12413ff75e15cd17d89a12ac6f49f74e9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 23 May 2013 12:47:23 -0400
Subject: [PATCH] Fix invalid option selected in default_font selector when font is unset (#1489112)

---
 CHANGELOG                       |    1 +
 program/steps/mail/compose.inc  |    2 +-
 program/steps/settings/func.inc |    9 +++++----
 config/main.inc.php.dist        |    2 +-
 program/steps/mail/sendmail.inc |    2 +-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 78272ff..88cea8c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix invalid option selected in default_font selector when font is unset (#1489112)
 - Fix displaying contact with ID divisible by 100 in sql addressbook (#1489121)
 - Fix browser warnings on PDF plugin detection (#1489118)
 - Fix fatal error when parsing UUencoded messages (#1489119)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index da5c5f3..4a73ff1 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -888,7 +888,7 @@
 // Default font for composed HTML message.
 // Supported values: Andale Mono, Arial, Arial Black, Book Antiqua, Courier New,
 // Georgia, Helvetica, Impact, Tahoma, Terminal, Times New Roman, Trebuchet MS, Verdana
-$rcmail_config['default_font'] = '';
+$rcmail_config['default_font'] = 'Verdana';
 
 // Enables display of email address with name instead of a name (and address in title)
 $rcmail_config['message_show_email'] = false;
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 5e1d95d..9ee57d3 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -143,7 +143,7 @@
 $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
 
 // default font for HTML editor
-$font = rcube_fontdefs($RCMAIL->config->get('default_font', 'Verdana'));
+$font = rcube_fontdefs($RCMAIL->config->get('default_font'));
 if ($font && !is_array($font)) {
   $OUTPUT->set_env('default_font', $font);
 }
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 2f96e93..cb3a405 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -479,7 +479,7 @@
 $message_body = get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_charset);
 
 if ($isHtml) {
-  $font   = rcube_fontdefs($RCMAIL->config->get('default_font', 'Verdana'));
+  $font   = rcube_fontdefs($RCMAIL->config->get('default_font'));
   $bstyle = $font && is_string($font) ? " style='font-family: $font'" : '';
 
   // append doctype and html/body wrappers
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 860f36c..ce86b1c 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -664,14 +664,15 @@
     }
 
     if (!isset($no_override['default_font'])) {
-      $field_id     = 'rcmfd_default_font';
-      $fonts        = rcube_fontdefs();
-      $default_font = $config['default_font'] ? $config['default_font'] : 'Verdana';
+      $field_id = 'rcmfd_default_font';
+      $fonts    = rcube_fontdefs();
+      $selected = $config['default_font'];
 
       $select = '<select name="_default_font" id="'.$field_id.'">';
+      $select .= '<option value=""' . (!$selected ? ' selected="selected"' : '') . '>---</option>';
       foreach ($fonts as $fname => $font)
         $select .= '<option value="'.$fname.'"'
-          . ($fname == $default_font ? ' selected="selected"' : '')
+          . ($fname == $selected ? ' selected="selected"' : '')
           . ' style=\'font-family: ' . $font . '\'>'
           . Q($fname) . '</option>';
       $select .= '</select>';

--
Gitblit v1.9.1