Fix inconsequent use of utf7_encode which causes problems with creating/renaming
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 28 Oct 2002 14:24:45 +0000 (14:24 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 28 Oct 2002 14:24:45 +0000 (14:24 +0000)
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
src/folders_create.php
src/folders_rename_getname.php

index f5ded3266f097f0400d946234c7b626742f54892..b981b4722d7f632cd5440f2e7fd02576c0bd036a 100755 (executable)
@@ -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));
             }
         }
index 604e65616c1ec42d973491d529b7ac120b8e218d..18d76fbf7492492d9b4577f71b68db15f16f6965 100644 (file)
@@ -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;
 }
index 6e494aa763ba35c29621e4623ac9d70be1b476f3..9c83612b8bf963a9a255a09c0ff404b4b3da0fcb 100644 (file)
@@ -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 '<br>' .
     html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) .