You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2008-10-22 17:20:17

Taras_
Member
From: Russia
Registered: 2006-04-25
Posts: 57
Website

CRLF in mail messages are disappeared (ticket creation by email)

I encounter a problem with body formatting in some tickets created by email: CRLF are truncated (all body without indentation). Problem seems to affect only HTML messages.

Fresh install of GLPI 0.71.2
Platform: FreeBSD 7.0-RELEASE/apache-2.2.9/php5-5.2.6/mysql-server-5.0.51a
Mail gateway on Exchange 2007 Std Ru SP1, connection via IMAP.
Mail to GLPI mailbox sent from gmail (both text and html).
No error messages from GLPI.


What direction should I look to solve this problem?

Thanks for help in advance.


Multiple GLPI instances. Thanks to developers! smile

Offline

#2 2008-10-27 09:43:13

Taras_
Member
From: Russia
Registered: 2006-04-25
Posts: 57
Website

Re: CRLF in mail messages are disappeared (ticket creation by email)

Looks like problem is located in html_clean() (common.function.php).
I'm absolutely dumb about regexps but  problem seems to be in stripping all HTML tags first and then trying to replace all <stripped> new line tags with '\n'.
Moving

$value = preg_replace("/<(p|br)( [^>]*)?".">/i", "\n", $value);

up resolved problem partially. After modification HTML messages from @gmail looks good, but messages from Outlook 2007/Exchange 2007 have too many new lines.

common.function.php

        $search = array('@<script[^>]*?>.*?</script[^>]*?>@si',  // Strip out javascript
               '@<style[^>]*?>.*?</style[^>]*?>@siU',    // Strip style tags properly
               '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
               '@<![\s\S]*?--[ \t\n\r]*>@'        // Strip multi-line comments including CDATA
        );
//// We are replacing all HTML tags here...
        $value = preg_replace($search, ' ', $value);

        $value = preg_replace("/(&nbsp;| )+/", " ", $value);
        // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
        $value = str_replace("’","'",$value);

//// ...and here we are trying to find <BR> and <P> and replace with '\n' but all tags are strip already.
        $value = preg_replace("/<(p|br)( [^>]*)?".">/i", "\n", $value);

        $value = preg_replace("/ +/u", " ", $value);
//      $value = preg_replace("/^\n+/", " ", $value);
//      $value = preg_replace("/\n+$/", " ", $value);

        $value = preg_replace("/\n{2,}/", "\n\n", $value,-1);

        return trim($value);
}

It'll be very good to review this function with experience of regexps in mind.

Last edited by Taras_ (2008-10-27 09:44:09)


Multiple GLPI instances. Thanks to developers! smile

Offline

#3 2009-01-18 20:56:15

Taras_
Member
From: Russia
Registered: 2006-04-25
Posts: 57
Website

Re: CRLF in mail messages are disappeared (ticket creation by email)

Does anybody encountered similar problem?


Multiple GLPI instances. Thanks to developers! smile

Offline

Board footer

Powered by FluxBB