From 6dc5eca489e0a529d9b6ac0316b7990701a0ec86 Mon Sep 17 00:00:00 2001 From: kink Date: Wed, 23 Jul 2003 11:27:36 +0000 Subject: [PATCH 1/1] off-by-one: when strlen == trim_at, we also don't want to print ... make code a little cleaner and get default trim_at value out of the fct git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5402 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox_display.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index e72c3c73..ae678a78 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -17,8 +17,12 @@ require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'class/html.class.php'); require_once(SM_PATH . 'functions/imap_mailbox.php'); -/* Default value for page_selector_max. */ +/* Constants: + * PG_SEL_MAX: default value for page_selector_max + * SUBJ_TRIM_AT: the length at which we trim off subjects + */ define('PG_SEL_MAX', 10); +define('SUBJ_TRIM_AT', 55); function elapsed($start) { @@ -1178,17 +1182,20 @@ function get_paginator_str($box, $start_msg, $end_msg, $num_msgs, function processSubject($subject, $threadlevel = 0) { global $languages, $squirrelmail_language; /* Shouldn't ever happen -- caught too many times in the IMAP functions */ - if ($subject == '') + if ($subject == '') { return _("(no subject)"); + } - $trim_at = 55; + $trim_at = SUBJ_TRIM_AT; /* if this is threaded, subtract two chars per indentlevel */ - if($threadlevel > 0 && $threadlevel <= 10) + if($threadlevel > 0 && $threadlevel <= 10) { $trim_at -= (2*$threadlevel); + } - if (strlen($subject) <= $trim_at) + if (strlen($subject) <= $trim_at) { return $subject; + } $ent_strlen = $orig_len = strlen($subject); $trim_val = $trim_at - 5; @@ -1223,7 +1230,7 @@ function processSubject($subject, $threadlevel = 0) { } // only print '...' when we're actually dropping part of the subject - if(strlen($subject) < $trim_val) { + if(strlen($subject) <= $trim_val) { return $subject; } else { return substr($subject, 0, $trim_val) . '...'; -- 2.25.1