Gnus development mailing list
 help / color / mirror / Atom feed
* iCalendar event without charset fails to display
@ 2022-01-29  8:59 Jae-hyeon Park
  2022-01-29 14:44 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Jae-hyeon Park @ 2022-01-29  8:59 UTC (permalink / raw)
  To: ding

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

Hello,

Gnus that comes with GNU Emacs 27.2 fails to display an iCalendar event
if it sets no "charset" parameter.  Strictly speaking, this does not
seem to be a Gnus' fault as section 3.1.4 of RFC5545 requires a
"charset" Content-Type parameter in MIME transports.  On the other hand,
there may be a buggy application that generates iCalendar streams in a
non-UTF-8 charset or does not specify the "charset" parameter.  The
attached patch would let Gnus tolerate these two types of bugs.

I hit the latter case where the "charset" property was missing, or more
precisely wrongly labelled "encoding":
======================================================================
Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  gnus-icalendar-event-from-handle((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil) ("Jae-hyeon Park" "email@address\\.com"))
  gnus-icalendar-mm-inline((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil))
  mm-display-inline((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil))
  mm-display-part((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil) t)
  gnus-mime-display-single((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil))
  gnus-mime-display-part((#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil))
  mapcar(gnus-mime-display-part ((#<buffer  *mm*-886772> ("text/plain" (charset . "utf-8")) 8bit (lambda nil (let ((inhibit-read-only t)) (delete-region #<marker (moves after insertion) at 7484 in *Article mail.list.physics.hep*> #<marker at 9377 in *Article mail.list.physics.hep*>))) ("inline") nil nil nil) (#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil)))
  gnus-mime-display-mixed(((#<buffer  *mm*-886772> ("text/plain" (charset . "utf-8")) 8bit (lambda nil (let ((inhibit-read-only t)) (delete-region #<marker (moves after insertion) at 7484 in *Article mail.list.physics.hep*> #<marker at 9377 in *Article mail.list.physics.hep*>))) ("inline") nil nil nil) (#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil)))
  gnus-mime-display-part((#("multipart/mixed" 0 15 (start nil from "seminar@organizer.org" buffer #<buffer  *mm*> boundary "===============5843370041342135681==")) (#<buffer  *mm*-886772> ("text/plain" (charset . "utf-8")) 8bit (lambda nil (let ((inhibit-read-only t)) (delete-region #<marker (moves after insertion) at 7484 in *Article mail.list.physics.hep*> #<marker at 9377 in *Article mail.list.physics.hep*>))) ("inline") nil nil nil) (#<buffer  *mm*-382724> ("text/calendar" (method . "REQUEST") (encoding . "utf-8") (filename . "event.ics")) nil nil nil nil nil nil)))
  gnus-display-mime()
  gnus-article-prepare-display()
  gnus-article-prepare(1787 nil)
  gnus-summary-display-article(1787)
  gnus-summary-next-page(nil)
  funcall-interactively(gnus-summary-next-page nil)
  call-interactively(gnus-summary-next-page nil nil)
  command-execute(gnus-summary-next-page)
======================================================================

Best regards,
Jae-hyeon

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-icalendar-missing-charset.diff --]
[-- Type: text/x-diff, Size: 923 bytes --]

diff -ru emacs-27.2.orig/lisp/gnus/gnus-icalendar.el emacs-27.2/lisp/gnus/gnus-icalendar.el
--- emacs-27.2.orig/lisp/gnus/gnus-icalendar.el	2021-01-29 02:52:38.000000000 +0900
+++ emacs-27.2/lisp/gnus/gnus-icalendar.el	2022-01-29 16:37:17.738632355 +0900
@@ -753,11 +753,12 @@
 (defmacro gnus-icalendar-with-decoded-handle (handle &rest body)
   "Execute BODY in buffer containing the decoded contents of HANDLE."
   (let ((charset (make-symbol "charset")))
-    `(let ((,charset (cdr (assoc 'charset (mm-handle-type ,handle)))))
+    `(let ((,charset (downcase
+		      (or (cdr (assoc 'charset (mm-handle-type ,handle)))
+			  "utf-8"))))
        (with-temp-buffer
          (mm-insert-part ,handle)
-         (when (string= (downcase ,charset) "utf-8")
-           (decode-coding-region (point-min) (point-max) 'utf-8))
+         (decode-coding-region (point-min) (point-max) (intern ,charset))
          ,@body))))
 
 

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

* Re: iCalendar event without charset fails to display
  2022-01-29  8:59 iCalendar event without charset fails to display Jae-hyeon Park
@ 2022-01-29 14:44 ` Lars Ingebrigtsen
  2022-02-16  5:09   ` Byung-Hee HWANG
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-29 14:44 UTC (permalink / raw)
  To: Jae-hyeon Park; +Cc: ding

Jae-hyeon Park <jhpark@kias.re.kr> writes:

> On the other hand, there may be a buggy application that generates
> iCalendar streams in a non-UTF-8 charset or does not specify the
> "charset" parameter.  The attached patch would let Gnus tolerate these
> two types of bugs.

Thanks; pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no


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

* Re: iCalendar event without charset fails to display
  2022-01-29 14:44 ` Lars Ingebrigtsen
@ 2022-02-16  5:09   ` Byung-Hee HWANG
  0 siblings, 0 replies; 3+ messages in thread
From: Byung-Hee HWANG @ 2022-02-16  5:09 UTC (permalink / raw)
  To: The Gnus

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Jae-hyeon Park <jhpark@kias.re.kr> writes:
>
>> On the other hand, there may be a buggy application that generates
>> iCalendar streams in a non-UTF-8 charset or does not specify the
>> "charset" parameter.  The attached patch would let Gnus tolerate these
>> two types of bugs.
>
> Thanks; pushed to Emacs 29.

Acknowledgments: Always thanks! Lars and Gnus users ^^^

Sincerely, Gnus fan Byung-Hee

-- 
황병희, 대숲농장
경북 울진군 평해읍 평오곡길 213-12 [36363]
비상 연락망: 010-7558-5952


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

end of thread, other threads:[~2022-02-16  5:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-29  8:59 iCalendar event without charset fails to display Jae-hyeon Park
2022-01-29 14:44 ` Lars Ingebrigtsen
2022-02-16  5:09   ` Byung-Hee HWANG

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 NNTP newsgroup(s).