ClearFoundation Tracker - ClearOS
View Issue Details
0000383ClearOSapp-flexshare - Flexsharespublic2011-10-25 03:332015-05-04 14:37
taryck 
 
normalfeaturealways
closedsuspended 
5.2-SP1 
 
0000383: email upload do not support RFC 2822 (MIME encoding os subject)
When you're using not 7-bit caracter like in french, spannish.
Like :
- "é"
- "ù"

It is not support by flexshare because e-mail subject is not decoded in class :
/var/webconfig/api/Flexshare.class.php
Method : FetchEmail
As describe in forum :
http://www.clearfoundation.com/component/option,com_kunena/Itemid,232/catid,13/func,view/id,31143/limit,10/limitstart,10/ [^]
I've made a decode function :
        /**
         * Encoded-Word decode
         * see mime encoding at http://en.wikipedia.org/wiki/MIME [^]
         * The form is: "=?charset?encoding?encoded text?=".
         * charset may be any character set registered with IANA. Typically it would be the same charset as the message body.
         * encoding can be either "Q" denoting Q-encoding that is similar to the quoted-printable encoding, or "B" denoting base64 encoding.
         * encoded text is the Q-encoded or base64-encoded text.
         *
         * @param string $text body or subject encoded
         * @returns string
         * @throws EngineException
         */
        function TBE_Decode_Word($text)
        {
                if (COMMON_DEBUG_MODE)
                        self::Log(COMMON_DEBUG, 'called', __METHOD__, __LINE__);

                try {
                        $decoded = $text;
                        $len = strlen($text);
                        if ($len > 4) {
                                if (substr($text,0,2) == "=?" && substr($text,$len-2,2) == "?=") {
// MIME encoded-Word
                                        if (COMMON_DEBUG_MODE)
                                                self::Log(COMMON_DEBUG, 'MIME encoded-Word detected', __METHOD__, __LINE__);
// $array = preg_split( "\?", $text);
                                        $array = split( "\?", $text);
/*
array (
        0 => '=',
        1 => 'ISO-8859-1',
        2 => 'B',
        3 => 'RGlyID0gdXNlcnMvbGF6ZXIvRG9jdW1lbnRzL1TpbOljb20v',
        4 => '=', )
*/
                                        switch($array[2]) {
                                                case 'Q' :
                                                        $decoded = quoted_printable_decode($array[3]);
                                                break;
                                                case 'B' :
                                                        $decoded = base64_decode($array[3]);
                                                break;
                                        }
                                }
                } catch (Exception $e) {
                        throw new EngineException ($e->GetMessage(), COMMON_ERROR);
                }
                return $decoded;
        }

But it do not works completly. Subject is decoded but code page is used and accent are not decoded properly

subject like : "=?ISO-8859-1?B?RGlyID0gdXNlcnMvbGF6ZXIvRG9jdW1lbnRzL1TpbOljb20v?="
become = "Dir = users/lazer/Documents/T?l?com/"
instead of "Dir = users/lazer/Documents/Télécom/"

May be you can improve this function to use code page and finalise the decoding....
No tags attached.
Issue History
2011-10-25 03:33taryckNew Issue
2011-10-25 17:29user2Statusnew => confirmed
2011-10-28 01:50taryckNote Added: 0000385
2015-05-04 14:37user2Statusconfirmed => resolved
2015-05-04 14:37user2Resolutionopen => suspended
2015-05-04 14:37user2Assigned To => user2
2015-05-04 14:37user2Statusresolved => closed
2015-05-04 14:37user2Assigned Touser2 =>

Notes
(0000385)
taryck   
2011-10-28 01:50   
Quite strange...
Before using my decode function Flex notification was :
[quote]The following emails having attachments are pending approval:

Flexshare: raid
Subject: =?ISO-8859-1?B?RGlyID0gdXNlcnMvbGF6ZXIvRG9jdW1lbnRzL1TpbOljb20v?=[/quote]
Now it's :
[quote]The following emails having attachments are pending approval:

Flexshare: raid
Subject: Dir = users/lazer/Documents/Télécom/[/quote]
Which is correct, no code page error.

But when I valid the mail in flexshare directory is rejected and document are delivred in email-upload directory.