[PATCH] skip over language specification in encoded words (RFC2231)

Dennis Preiser <[email protected]> Thu, 17 Dec 2015 20:09:47 +0100
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

RFC2231 defines optional language specifications in encoded words. tin
is not aware of those tags and thus decoding fails.

Here is an article which shows this issue (subject with language
specifications):

| Newsgroups: de.alt.test
| Message-ID: <[email protected]>

The attached patch simply skips over those definitions.

Dennis

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="2015-12-17.diff"

--- tin-2.3.2_r5/src/rfc2047.c	2015-11-22 01:14:31.000000000 +0100
+++ tin-2.3.2_r6/src/rfc2047.c	2015-12-17 19:56:11.000000000 +0100
@@ -279,8 +279,15 @@ rfc1522_decode(
 
 			e = charset;
 			c++;
-			while (*c && *c != '?')
+			while (*c && *c != '?') {
+				/* skip over optional language tags (RFC2231, RFC5646) */
+				if (*c == '*') {
+					while (*++c && *c != '?')
+						;
+					continue;
+				}
 				*e++ = *c++;
+			}
 			*e = 0;
 			if (*c == '?') {
 				c++;

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KdGluLWRldiBt
YWlsaW5nIGxpc3QKdGluLWRldkB0aW4ub3JnCmh0dHA6Ly9saXN0cy50aW4ub3JnL2NnaS1iaW4v
bWFpbG1hbi9saXN0aW5mby90aW4tZGV2Cg==

--ew6BAiZeqk4r7MaW--