From 32ac953986e99d59cde010ee0c506609ad0a3444 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 05 May 2008 08:56:39 -0400
Subject: [PATCH] - Fix management of folders with national characters in names (#1485036, #1485001)

---
 CHANGELOG                                 |    1 +
 program/steps/settings/manage_folders.inc |   18 ++++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index c586bce..a7c1990 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
 ----------
 - Installer: encode special characters in DB username/password (#1485042)
 - Do charset conversion also for from/to column on messages list
+- Fix management of folders with national characters in names (#1485036, #1485001)
 
 2008/05/02 (alec)
 ----------
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
index 49f9491..4de8c2c 100644
--- a/program/steps/settings/manage_folders.inc
+++ b/program/steps/settings/manage_folders.inc
@@ -46,8 +46,13 @@
 else if ($RCMAIL->action=='create-folder')
   {
   if (!empty($_POST['_name']))
-    $create = $IMAP->create_mailbox(trim(get_input_value('_name', RCUBE_INPUT_POST, FALSE, 'UTF-7')), TRUE);
-
+    {
+    $name = trim(get_input_value('_name', RCUBE_INPUT_POST, FALSE, 'UTF-7'));
+     // #1485036 (RFC3501, 5.1.3) TODO: it should be done on read not on write
+    $name = str_replace('&-', '&', $name);
+    $create = $IMAP->create_mailbox($name, TRUE);
+    }
+  
   if ($create && $OUTPUT->ajax_call)
     {
     $delimiter = $IMAP->get_hierarchy_delimiter();
@@ -65,8 +70,13 @@
 else if ($RCMAIL->action=='rename-folder')
   {
   if (!empty($_POST['_folder_oldname']) && !empty($_POST['_folder_newname']))
-    $rename = $IMAP->rename_mailbox(($oldname = get_input_value('_folder_oldname', RCUBE_INPUT_POST)), trim(get_input_value('_folder_newname', RCUBE_INPUT_POST, FALSE, 'UTF-7')));
-    
+    {
+    $name = trim(get_input_value('_folder_newname', RCUBE_INPUT_POST, FALSE, 'UTF-7'));
+     // #1485036 (RFC3501, 5.1.3) TODO: it should be done on read not on write
+    $name = str_replace('&-', '&', $name);
+    $rename = $IMAP->rename_mailbox(($oldname = get_input_value('_folder_oldname', RCUBE_INPUT_POST)), $name);
+    }
+
   if ($rename && $OUTPUT->ajax_call)
     {
     $a_mboxes = array_unique(array_merge($IMAP->list_mailboxes(), $IMAP->list_unsubscribed()));

--
Gitblit v1.9.1