From: tokul Date: Sat, 31 Jul 2004 12:35:44 +0000 (+0000) Subject: Adding size limit to signature. Max size is the same as db BLOB size. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=288df1a09d98fc7a455cbab2fceca36d00508328 Adding size limit to signature. Max size is the same as db BLOB size. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7816 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index 10e3d5b2..6d3d806a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,9 @@ Version 1.5.1 -- CVS reply focus to "No focus" also affects composing new messages) - Current hook name is now globally available when running a hook ($currentHookName) - Fix bug when Saving to Draft folder that contains special characters. + - Added size limit to signatures saved in file backend. Created error_option_save + function, that allows sending error message to options page. Thanks to Martynas + Bieliauskas for spotting big signature "option". Version 1.5.0 -------------------- diff --git a/functions/display_messages.php b/functions/display_messages.php index fae48f5d..963f48f5 100644 --- a/functions/display_messages.php +++ b/functions/display_messages.php @@ -163,5 +163,18 @@ function error_box($string, $color) { ''; } +/** + * Adds message that informs about non fatal error that can happen while saving preferences + * @param string $message error message + * @since 1.5.1 + */ +function error_option_save($message) { + global $optpage_save_error; + + if (! is_array($optpage_save_error) ) + $optpage_save_error=array(); + + $optpage_save_error=array_merge($optpage_save_error,array($message)); +} // vim: et ts=4 ?> \ No newline at end of file diff --git a/functions/file_prefs.php b/functions/file_prefs.php index 2cc152d1..a6cfc6d8 100644 --- a/functions/file_prefs.php +++ b/functions/file_prefs.php @@ -223,6 +223,11 @@ function checkForPrefs($data_dir, $username, $filename = '') { * Write the User Signature. */ function setSig($data_dir, $username, $number, $value) { + // Limit signature size to 64KB (database BLOB limit) + if (strlen($value)>65536) { + error_option_save(_("Signature is too big.")); + return; + } $filename = getHashedFile($username, $data_dir, "$username.si$number"); /* Open the file for writing, or else display an error to the user. */ if(!$file = @fopen("$filename.tmp", 'w')) { diff --git a/src/options.php b/src/options.php index 42ecaedd..9a2e3f14 100644 --- a/src/options.php +++ b/src/options.php @@ -210,6 +210,8 @@ if ( !@is_file( $optpage_file ) ) { /*** Next, process anything that needs to be processed. ***/ /***********************************************************/ +$optpage_save_error=array(); + if ( isset( $optpage_data ) ) { switch ($optmode) { case SMOPT_MODE_SUBMIT: @@ -289,8 +291,19 @@ if ($optpage == SMOPT_PAGE_MAIN) { if (!isset($frame_top)) { $frame_top = '_top'; } - /* Display a message indicating a successful save. */ - echo '' . _("Successfully Saved Options") . ": $optpage_name
\n"; + + if (isset($optpage_save_error) && $optpage_save_error!=array()) { + echo "" . _("Error(s) happened while saving your options") . "
\n"; + echo "\n"; + echo '' . _("Some of your preference changes are not applied.") . "
\n"; + } else { + /* Display a message indicating a successful save. */ + echo '' . _("Successfully Saved Options") . ": $optpage_name
\n"; + } /* If $max_refresh != SMOPT_REFRESH_NONE, provide a refresh link. */ if ( !isset( $max_refresh ) ) {