From 68f2ce7a0841a249b4ba8d0a1a89a60c11f3d255 Mon Sep 17 00:00:00 2001 From: kink Date: Mon, 28 Oct 2002 14:24:45 +0000 Subject: [PATCH] Fix inconsequent use of utf7_encode which causes problems with creating/renaming folders with special chars like '&': sometimes doesn't get encoded, other times does, sometimes gets encoded twice. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4049 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_mailbox.php | 23 ++++++++++++++--------- src/folders_create.php | 2 ++ src/folders_rename_getname.php | 4 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index f5ded326..b981b472 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -276,31 +276,36 @@ function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) { } else { $postfix = ''; } + + $old_name = imap_utf7_encode_local($old_name); + $new_name = imap_utf7_encode_local($new_name); + $boxesall = sqimap_mailbox_list($imap_stream); - $cmd = 'RENAME "' . quoteIMAP($old_name) . '" "' . quoteIMAP($new_name) . '"'; + $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name.$postfix); - $oldpref = getPref($data_dir, $username, "thread_".$old_name.$postfix); - removePref($data_dir, $username, "thread_".$old_name.$postfix); + $oldpref = getPref($data_dir, $username, 'thread_'.$old_name.$postfix); + removePref($data_dir, $username, 'thread_'.$old_name.$postfix); sqimap_subscribe($imap_stream, $new_name.$postfix); - setPref($data_dir, $username, "thread_".$new_name.$postfix, $oldpref); + setPref($data_dir, $username, 'thread_'.$new_name.$postfix, $oldpref); do_hook_function("rename_or_delete_folder",$args = array($old_name, 'rename', $new_name)); $l = strlen( $old_name ) + 1; $p = 'unformatted'; + foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); if ($imap_server_type == 'cyrus') { - $cmd = 'RENAME "' . quoteIMAP($box[$p]) . '" "' . quoteIMAP($new_sub) . '"'; + $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); } sqimap_unsubscribe($imap_stream, $box[$p]); - $oldpref = getPref($data_dir, $username, "thread_".$box[$p]); - removePref($data_dir, $username, "thread_".$box[$p]); + $oldpref = getPref($data_dir, $username, 'thread_'.$box[$p]); + removePref($data_dir, $username, 'thread_'.$box[$p]); sqimap_subscribe($imap_stream, $new_sub); - setPref($data_dir, $username, "thread_".$new_sub, $oldpref); - do_hook_function("rename_or_delete_folder", + setPref($data_dir, $username, 'thread_'.$new_sub, $oldpref); + do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } diff --git a/src/folders_create.php b/src/folders_create.php index 604e6561..18d76fbf 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -46,6 +46,8 @@ if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || exit; } +$subfolder = imap_utf7_decode_local($subfolder); + if (isset($contain_subs) && $contain_subs ) { $folder_name = $folder_name . $delimiter; } diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index 6e494aa7..9c83612b 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -17,6 +17,7 @@ define('SM_PATH','../'); /* SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/imap_mailbox.php'); require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'functions/display_messages.php'); @@ -46,6 +47,8 @@ if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) { $isfolder = FALSE; } +$old = imap_utf7_decode_local($old); + if (strpos($old, $delimiter)) { $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old)); $old_parent = substr($old, 0, strrpos($old, $delimiter)); @@ -54,6 +57,7 @@ if (strpos($old, $delimiter)) { $old_parent = ''; } + displayPageHeader($color, 'None'); echo '
' . html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) . -- 2.25.1