#295 folder sorting goes wrong with special chars

open
nobody
Folders (53)
5
2003-05-13
2003-05-13
Michael Tuschik
No

Hello,

(don't know, if i have to report this as a bug first ?)

Let's say i have four folders like:

Debian-Security
Debian-Security.2003
Debian-Security-Announce
Debian-Security-Announce.2003

SquirrelMail (1.4.0) shows me the folder list as follows:

Debian-Security
- Debian-Security-Announce
2003
2003

So the subfolder "2003" of "Debian-Security" is not sorted
correctly. I investigated this problem a bit and found the
function "user_strcasecmp" in file "imap_mailbox.php"
which is responsible for this (i think). I've written a small
piece of code which splits the long foldernames into parts
and compares them. This shows my folders in the right
order:

function user_strcasecmp($a, $b) {
global $delimiter;

$a_arr = explode($delimiter, $a);
$b_arr = explode($delimiter, $b);
$a_cnt = count($a_arr);
$b_cnt = count($b_arr);
for ( $i = 0; $i < $a_cnt && $i < $b_cnt; ++$i ) {
$r = strnatcasecmp($a_arr[$i], $b_arr[$i]);
if ( $r != 0 ) return $r;
}
return strnatcmp($a_cnt, $b_cnt);
}

best regards
Michael

Discussion