Wrong charset regex in mime_decode.php

Post Reply
weevsolutions
Posts: 6
Joined: 16 Jan 2021, 06:19
Name: Ettore Perri
Location: Italy Lamezia Terme
Company Name: Weev Solutions di Perri Ettore

Wrong charset regex in mime_decode.php

Post by weevsolutions »

Hi, the regex /charset=["\']?([^"\']*)/i' at line 297 matches 'iso-8859-15; format=flowed' instead of 'iso-8859-15'
I've replaced the regex with: "/charset=[\"|\']*([^\;|^\n|^\"|^\']*)[\"|\'|\;]*/i" and seems to work.

The bug causes body text truncation using special chars like € or à encoded in iso-8859


__
edit 19.29: updated regex
weevsolutions
Posts: 6
Joined: 16 Jan 2021, 06:19
Name: Ettore Perri
Location: Italy Lamezia Terme
Company Name: Weev Solutions di Perri Ettore

Re: Wrong charset regex in mime_decode.php

Post by weevsolutions »

The bug is still present in 2.8.1.


Bug scenario:
If the charset is not the last parameter of Content-Type and if special characters are present in mail body the message is truncated.

Example of Content-Type:
Content-Type: text/plain; charset=iso-8859-15; format=flowed

Solution:
Replace the line 297 of ext/classes/mail/mime_decode.php with this:

Code: Select all

 if(preg_match('/charset=[\"|\']*([^\;|^\n|^\"|^\']*)[\"|\'|\;]*/i', $headers[$key]['value'], $matches))
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong charset regex in mime_decode.php

Post by support »

Strange, I naver had issue like hits. But anyway I have done this modification. See attached.
This fix will be for 2.8.2
Attachments
mime_decode.zip
(9.58 KiB) Downloaded 75 times
weevsolutions
Posts: 6
Joined: 16 Jan 2021, 06:19
Name: Ettore Perri
Location: Italy Lamezia Terme
Company Name: Weev Solutions di Perri Ettore

Re: Wrong charset regex in mime_decode.php

Post by weevsolutions »

Hi, if you want to check this behaviour I can send an email to a your integrated account.
Regards
weevsolutions
Posts: 6
Joined: 16 Jan 2021, 06:19
Name: Ettore Perri
Location: Italy Lamezia Terme
Company Name: Weev Solutions di Perri Ettore

Re: Wrong charset regex in mime_decode.php

Post by weevsolutions »

this one is better..

/charset=[\"\']*([^\;\n\"\']*)/i
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong charset regex in mime_decode.php

Post by support »

ok, updated. This fix will be in 2.8.2
Attachments
mime_decode.zip
(9.57 KiB) Downloaded 82 times
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Wrong charset regex in mime_decode.php

Post by support »

So it works ok for you now?
weevsolutions
Posts: 6
Joined: 16 Jan 2021, 06:19
Name: Ettore Perri
Location: Italy Lamezia Terme
Company Name: Weev Solutions di Perri Ettore

Re: Wrong charset regex in mime_decode.php

Post by weevsolutions »

changing the regex it works ok
Post Reply