Use a sane default encoding for messages that do not define their encoding

mfb - September 17, 2009 - 22:29
Project:Mailhandler
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:fixed
Description

I found that messages from txt.att.net do not define their encoding. If the encoding is undefined, messages with "illegal" characters will be cut off. For example, "Mañana" becomes "Ma". Most e-mail clients are able to deal with undefined encodings and I suggest mailhandler should be able to as well, by using a sane default encoding.

Sample code to reproduce this issue:

<?php
drupal_set_message
(drupal_convert_to_utf8('Mañana', NULL));
?>

This patch defines the default encoding as Windows-1252, which in my experience is the most common encoding for e-mail messages that do not define their encoding.

AttachmentSize
encoding.patch803 bytes

#1

Ian Ward - October 14, 2009 - 18:40

@mfb what do you think allowing default/fallback encoding to be set per-mailbox?

#2

mfb - October 14, 2009 - 18:56

I don't need such a setting myself but sure, if it's useful for someone :)

#3

darioarg - November 13, 2009 - 18:14

Awesome!!, I lost many time finding what I need do to fix it. Thanks!!!, may be this move to stable version?

Gracias!, supongo que el uso de la Ñ te hace de habla hispana o tienes clientes de habla hispana. Saludos!!

#4

z.stolar - November 15, 2009 - 15:25

I'd use UTF-8 to encourage more people to use it as their default encoding, and if we set it, it should probably be configurable.

I'm not sure it should be a per-mailbox setting. It seem to me it would be more useful as a site-wide configuration, so if it needs to be changed, it should only be changed once (I don't expect anyone to change it more than once on a site)

#5

Ian Ward - November 22, 2009 - 14:22

@z.stolar Agreed - site wide setting seems sufficient. What's the best way to offer this setting on the user interface? A textfield like in the attached patch, defaulted to UTF-8?

AttachmentSize
mailhandler-580810-5.patch 2.13 KB

#6

z.stolar - November 22, 2009 - 17:30

Yes, that seem like the right place to do it.

#7

Ian Ward - November 22, 2009 - 19:14
Status:needs review» fixed

I applied the patch in #5 to 6.1. Will apply to 6.2 as well. Marking this as fixed.

 
 

Drupal is a registered trademark of Dries Buytaert.