From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#35507: Gnus mojibakifies UTF-8 text/x-patch attachments from Thunderbird Date: Tue, 30 Apr 2019 12:20:58 -0700 Organization: UCLA Computer Science Department Message-ID: <44a26585-7980-378c-9262-a567ddd3e617@cs.ucla.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------774ADBE11107067D28CE4369" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="168797"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 To: 35507@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 30 21:24:48 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLYMx-000hjw-96 for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Apr 2019 21:24:47 +0200 Original-Received: from localhost ([127.0.0.1]:52114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLYMv-0003GH-S0 for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Apr 2019 15:24:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLYMh-0003AH-01 for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 15:24:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLYKK-0002rV-6h for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 15:22:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLYKI-0002qo-OK for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2019 15:22:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hLYKI-0001Vq-BN; Tue, 30 Apr 2019 15:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Tue, 30 Apr 2019 19:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35507 X-GNU-PR-Package: emacs,gnus X-Debbugs-Original-To: submit@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15566520715752 (code B ref -1); Tue, 30 Apr 2019 19:22:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Apr 2019 19:21:11 +0000 Original-Received: from localhost ([127.0.0.1]:42411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLYJQ-0001Uf-Qz for submit@debbugs.gnu.org; Tue, 30 Apr 2019 15:21:11 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hLYJO-0001Tr-0r for submit@debbugs.gnu.org; Tue, 30 Apr 2019 15:21:07 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 20BC8161897 for ; Tue, 30 Apr 2019 12:21:00 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nmwtW2V3lcvZ for ; Tue, 30 Apr 2019 12:20:58 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BBE671618AC for ; Tue, 30 Apr 2019 12:20:58 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id sMZuKignGArd for ; Tue, 30 Apr 2019 12:20:58 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9BBEA16180D for ; Tue, 30 Apr 2019 12:20:58 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158529 Archived-At: This is a multi-part message in MIME format. --------------774ADBE11107067D28CE4369 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Package: emacs,gnus Version: 27 When I send email from Thunderbird with a patch attachment, Thunderbird puts something like the following into the email: =C2=A0 --------------AA6C74B60F40E0D600CCD03A =C2=A0 Content-Type: text/x-patch; =C2=A0=C2=A0 name=3D"0001-Fix-decode-time-encode-time-roundtrip-on-macOS.= patch" =C2=A0 Content-Transfer-Encoding: 8bit =C2=A0 Content-Disposition: attachment; =C2=A0=C2=A0 filename*0=3D"0001-Fix-decode-time-encode-time-roundtrip-on-= macOS.patch" =C2=A0 From 325f51c84d9ad4d9776784bd324b347ffe4fe51b Mon Sep 17 00:00:00 = 2001 =C2=A0 From: Paul Eggert =C2=A0 Date: Tue, 30 Apr 2019 10:45:48 -0700 =C2=A0 Subject: [PATCH] Fix decode-time/encode-time roundtrip on macOS =C2=A0 MIME-Version: 1.0 =C2=A0 Content-Type: text/plain; charset=3DUTF-8 =C2=A0 Content-Transfer-Encoding: 8bit =C2=A0 * src/timefns.c (Fencode_time): Ignore DST flag when the zone is =C2=A0 ... The attachment has a text/* media type but it has no charset parameter. The patch itself (output by git format-patch) says its charset is UTF-8. Unfortunately, Gnus doesn't recognize the patch as UTF-8 and so mishandles the non-ASCII characters in the attachment. To reproduce the problem, read this email with Gnus; the full attachment is attached to this email in the Thunderbird way. Although Internet RFC 2046 section 4.1.2 says the default charset for text/* media types is US-ASCII, Internet RFC 6557 section 3 amends this to say that registered text/* media types should require a charset specification (or should say it's not needed because the payload has that info, which obviously doesn't apply here). It later says that if there is a strong reason to have a charset default, the default should be UTF-8. Unfortunately Gnus apparently doesn't default to UTF-8 for such attachments, which means that sending a text/x-patch attachment from Thunderbird to Gnus messes up if the attachment contains non-ASCII characters. This has been causing problems on the Emacs mailing list for years and it bit a correspondent of mine again today; see . I have filed a Thunderbird bug report for this, as Thunderbird should specify a charset; see . However, Gnus should be a polite citizen and handle these attachments nicely rather than converting the non-ASCII UTF-8 characters to mojibake. --------------774ADBE11107067D28CE4369 Content-Type: text/x-patch; name="0001-Fix-decode-time-encode-time-roundtrip-on-macOS.patch" Content-Disposition: attachment; filename*0="0001-Fix-decode-time-encode-time-roundtrip-on-macOS.patch" Content-Transfer-Encoding: quoted-printable >From 325f51c84d9ad4d9776784bd324b347ffe4fe51b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 30 Apr 2019 10:45:48 -0700 Subject: [PATCH] Fix decode-time/encode-time roundtrip on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * src/timefns.c (Fencode_time): Ignore DST flag when the zone is numeric or is a cons, as the doc string says it=E2=80=99s ignored in that case, and not ignoring it causes encode-time to not invert decode-time on some platforms (Bug#35502). * test/src/timefns-tests.el (encode-time-dst-numeric-zone): New test. --- src/timefns.c | 5 +++-- test/src/timefns-tests.el | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/timefns.c b/src/timefns.c index 5005c73b7f..7b5af6a5d2 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBS= OLESCENT-ARGUMENTS) */) tm.tm_mon =3D check_tm_member (XCAR (a), 1); a =3D XCDR (a); tm.tm_year =3D check_tm_member (XCAR (a), TM_YEAR_BASE); a =3D XCD= R (a); a =3D XCDR (a); - if (SYMBOLP (XCAR (a))) - tm.tm_isdst =3D !NILP (XCAR (a)); + Lisp_Object dstflag =3D XCAR (a); a =3D XCDR (a); zone =3D XCAR (a); + if (SYMBOLP (dstflag) && !FIXNUMP (zone) && !CONSP (zone)) + tm.tm_isdst =3D !NILP (dstflag); } else if (nargs < 6) xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nar= gs)); diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index 5c858ef3bd..2c90af757f 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el @@ -142,3 +142,9 @@ timefns-tests--have-leap-seconds (< 0.99 (/ x y) 1.01) (< 0.99 (/ (- (float-time a)) (float-time b)) 1.01)))))))) + +(ert-deftest encode-time-dst-numeric-zone () + "Check for Bug#35502." + (should (time-equal-p + (encode-time '(29 31 17 30 4 2019 2 t 7200)) + '(23752 27217)))) --=20 2.20.1 --------------774ADBE11107067D28CE4369--