unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Handling mislabeled emails encoded with Windows-1252
@ 2018-07-14 12:40 Sebastian Poeplau
  2018-07-24  1:49 ` David Bremner
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastian Poeplau @ 2018-07-14 12:40 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]

Hi,

This email is to suggest a minor change in how notmuch handles text
encoding when displaying emails. The motivation is the following: I keep
receiving emails that are encoded with Windows-1252 but claim to be
ISO 8859-1. The two character sets only differ in the range between 0x80
and 0x9F where Windows-1252 contains special characters (e.g. “quotation
marks”) while ISO 8859-1 only has non-printable ones. The mislabeling
thus causes some special characters in such emails to be displayed with
a replacement symbol for non-printable characters.

Of course, it would be best to fix the problem on the sender's side,
making their mail client declare the encoding correctly. However,
sometimes this is just not possible and we need to make do with what we
receive. The change I would thus like to suggest is to always treat
ISO 8859-1 as Windows-1252; since the former only contains non-printable
characters in the range where the two differ, we would not lose any
printable information. According to Wikipedia, this substitution is
common in email clients and browsers because of the frequent
mislabeling [1].

Attached you find a simple patch that illustrates my suggestion. While
it works well for my limited use cases, it's obviously not entirely
reliable. Does anyone have a good idea how to better handle the issue? I
searched GMime for related functionality but didn't quite find what I
was looking for. Do you feel that the issue should be raised with the
GMime people instead?

Best regards,
Sebastian

[1] https://en.wikipedia.org/wiki/ISO/IEC_8859-1#Windows-1252


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: charset.patch --]
[-- Type: text/x-patch, Size: 609 bytes --]

diff -ura notmuch-0.27/notmuch-show.c notmuch-0.27-patched/notmuch-show.c
--- notmuch-0.27/notmuch-show.c	2018-06-13 03:42:34.000000000 +0200
+++ notmuch-0.27-patched/notmuch-show.c	2018-07-11 10:32:56.000456518 +0200
@@ -291,6 +291,8 @@
     charset = g_mime_object_get_content_type_parameter (part, "charset");
     if (charset) {
 	GMimeFilter *charset_filter;
+	if (!strcmp(charset, "iso-8859-1"))
+	    charset = "CP1252";
 	charset_filter = g_mime_filter_charset_new (charset, "UTF-8");
 	/* This result can be NULL for things like "unknown-8bit".
 	 * Don't set a NULL filter as that makes GMime print

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-07-31  9:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-14 12:40 Handling mislabeled emails encoded with Windows-1252 Sebastian Poeplau
2018-07-24  1:49 ` David Bremner
2018-07-24  8:00   ` Sebastian Poeplau
2018-07-24 13:55     ` Sebastian Poeplau
2018-07-24 14:09   ` Jeffrey Stedfast
2018-07-24 14:19     ` Sebastian Poeplau
2018-07-28 11:22       ` Sebastian Poeplau
2018-07-28 12:25         ` Jeffrey Stedfast
2018-07-30  7:28           ` Sebastian Poeplau
2018-07-30  7:47             ` Sebastian Poeplau
2018-07-31  9:07               ` David Bremner
2018-07-31  9:49                 ` Sebastian Poeplau

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).