[#14429] Procmail rule with Umlaut wrong folder because backslash
Summary Procmail rule with Umlaut wrong folder because backslash
Queue Ingo
Queue Version 3.2.11
Type Bug
State Resolved
Priority 1. Low
Owners mrubinsk@horde.org
Requester samuel.wolf@wolf-maschinenbau.de
Created 2016-07-27 (1208 days ago)
Due
Updated 2017-10-20 (758 days ago)
Assigned 2016-07-31 (1204 days ago)
Resolved 2016-08-01 (1203 days ago)
Milestone
Patch No

Comments
samuel.wolf@wolf-maschinenbau.de 2016-07-27 16:22:10
I have a folder "Umlaute-ä" in IMP / my maildir.

Create a filte rule with Ingo "Deliver to folder... [Umlaute-ä]" 
generate following procmail script:
[...]
140: ##### Horde #####
141: :0
142: * ^From:.*@horde\.org
143: ".Umlaute-\&AOQ-/"

But the folder in the maildir is named ".Umlaute-&AOQ-", as soon the 
filter match procmail create a new folder named ".Umlaute-\&AOQ-" and 
deliver the mail into it.

Git Commit <commits@lists.horde.org> 2016-07-29 15:17:41
Changes have been made in Git (master):

commit 58f170c7ce44f73f9d96516e42459179864f27eb
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Fri Jul 29 11:17:06 2016 -0400

     Bug: 14429 Escape mailbox before converting to utf7imap.

  ingo/lib/Script/Procmail/Recipe.php | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

http://github.com/horde/horde/commit/58f170c7ce44f73f9d96516e42459179864f27eb

Git Commit <commits@lists.horde.org> 2016-07-29 15:23:38
Changes have been made in Git (FRAMEWORK_5_2):

commit fba0d5ff4d8f74f3ca6ccf5e60664db0d0c8d4f4
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Fri Jul 29 11:17:06 2016 -0400

     Bug: 14429 Escape mailbox before converting to utf7imap.

  ingo/lib/Script/Procmail/Recipe.php | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

http://github.com/horde/horde/commit/fba0d5ff4d8f74f3ca6ccf5e60664db0d0c8d4f4

Michael Rubinsky <mrubinsk@horde.org> 2016-07-29 15:24:26
Ingo 3.2.12

samuel.wolf@wolf-maschinenbau.de 2016-07-31 15:51:21
> http://github.com/horde/horde/commit/fba0d5ff4d8f74f3ca6ccf5e60664db0d0c8d4f4
Apply this patch to Ingo 3.2.11

But the procmail script missing the Umlaut now completely:
##### Horde #####
:0
* ^From:.*@horde\.org
".Umlaute-/"

Michael Rubinsky <mrubinsk@horde.org> 2016-07-31 20:51:26
Cannot reproduce this.

Are you sure the changes were applied correctly? The lines in question 
in  ingo/lib/Script/Procmail/Recipe.php should look like this 
(starting at line 470):

             $mbox = new Horde_Imap_Client_Mailbox(escapeshellcmd($folder));
             return '".' . $mbox->utf7imap . '/"';

Michael Rubinsky <mrubinsk@horde.org> 2016-07-31 21:22:13
What version of PHP are you using? There were bugs in earlier versions 
with regard to special characters and escapeshell* functions.

samuel.wolf@wolf-maschinenbau.de 2016-07-31 21:54:06
> Are you sure the changes were applied correctly?
root@wolfmailserver:/var/www/https/horde# tail 
ingo/lib/Script/Procmail/Recipe.php
                 $folder = substr($folder, 6);
             }

            $mbox = new Horde_Imap_Client_Mailbox(escapeshellcmd($folder));

            return '".' . $mbox->utf7imap . '/"';
         }
         return str_replace(' ', '\ ', escapeshellcmd($folder));
     }
}
root@wolfmailserver:/var/www/https/horde#

> What version of PHP are you using?
php5-common 5.6.24+dfsg-0+deb8u1 amd64

Michael Rubinsky <mrubinsk@horde.org> 2016-07-31 22:01:06
Can you get the output of:

phpinfo();


from within the administrative phpshell page? Specifically, the LC_ALL 
or LANG environment variables.


samuel.wolf@wolf-maschinenbau.de 2016-07-31 22:04:39
> Specifically, the LC_ALL or LANG environment variables.
LC_ALL         de_DE.UTF-8

LANGUAGE         de_DE.UTF-8


Michael Rubinsky <mrubinsk@horde.org> 2016-07-31 22:41:42
Maybe https://bugs.php.net/bug.php?id=54391, though not sure why it's 
not happening on my system.

Michael Rubinsky <mrubinsk@horde.org> 2016-08-01 03:21:03
Actually, this is all moot anyway. For utf7-imap encoded mailbox 
names, using escapeshellcmd will corrupt mailbox names that contain 
things like '&' anyway since these are encoded in a different way. 
I.e, we can't escape here anyway.

Fixed in Git:
https://github.com/horde/horde/commit/fe8e7606e6e06626f574877b0ff0e6e1f963d099

samuel.wolf@wolf-maschinenbau.de 2016-08-01 08:14:59

Git Commit <commits@lists.horde.org> 2017-10-20 20:33:42
Changes have been made in Git (FRAMEWORK_5_2):

commit 657fa85d249ba4bf7a62f51f7be78bf7289b8943
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Fri, 29 Jul 2016 11:22:10 -0400

Bug: 14429 Escape mailbox before converting to utf7imap.

  M lib/Script/Procmail/Recipe.php

https://github.com/horde/ingo/commit/657fa85d249ba4bf7a62f51f7be78bf7289b8943