Helge Titlestad
2009-Oct-19 14:07 UTC
[sup-talk] [PATCH] detect and set charset on text/* attachments
I got some feedback from non-suppers that my utf-8 text attachments were messed up. When I checked they (the MIME headers) lacked any info on charset, which I believe should be set for text/*. Here''s a patch that uses the chardet gem to (try to) detect the appropriate charset and sets it in the Content-Type header. Can''t guarantee its robustness - have only tried on a couple of text files and one non-text file. Please tell me if I should use some different way of sending patches... This git flow is a bit new to me. (-- alge -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Detect-charset-for-text-file-attachments.patch Type: application/octet-stream Size: 1927 bytes Desc: not available URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20091019/474102fe/attachment.obj>
William Morgan
2009-Nov-03 17:16 UTC
[sup-talk] [PATCH] detect and set charset on text/* attachments
Reformatted excerpts from Helge Titlestad''s message of 2009-10-19:> I got some feedback from non-suppers that my utf-8 text attachments > were messed up. When I checked they (the MIME headers) lacked any info > on charset, which I believe should be set for text/*.After reviewing the RFCs, yeah, I think you''re basically right. The charset parameter is not required to be set for text/* mime types, but if it''s unset, the part is assumed to be us-ascii.> Here''s a patch that uses the chardet gem to (try to) detect the > appropriate charset and sets it in the Content-Type header.Although I don''t relish adding yet another gem dependency, I think this is the right approach. It looks like the chardet gem is unmaintained. But someone decided to make their own special version called rchardet which is completely equivalent version but *is* maintained. (What is it with these goddamn ruby people.) I suggest we use rchardet instead of chardet. Would you like to change the patch? If not, I will get to it at some point.> Please tell me if I should use some different way of sending > patches... This git flow is a bit new to me. (Nope, this is perfect. Thanks! -- William <wmorgan-sup at masanjin.net>
Helge Titlestad
2009-Nov-03 19:23 UTC
[sup-talk] [PATCH] detect and set charset on text/* attachments
Excerpts from William Morgan''s message of Tue Nov 03 18:16:32 +0100 2009:> It looks like the chardet gem is unmaintained. But someone decided to > make their own special version called rchardet which is completely > equivalent version but *is* maintained. > > I suggest we use rchardet instead of chardet. Would you like to change > the patch? If not, I will get to it at some point.Here you go! One thing I noticed when trying it out: It will set charset ''ascii'' for ascii text, which is allowed by the RFC but "US-ASCII" is preferred. I think I prefer to not create a special case in the code to change it to US-ASCII or remove the charset for ascii text, but other people might disagree. -- alge -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Detect-charset-for-text-file-attachments.patch Type: application/octet-stream Size: 1919 bytes Desc: not available URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20091103/bcbaa6d8/attachment.obj>