diff options
| author | Eli Zaretskii | 2015-02-28 14:03:34 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-02-28 14:03:34 +0200 |
| commit | 31ecbf8d513540855aa07588f6746942aed453ba (patch) | |
| tree | 0b2389ed3bfa8928f8f65473a0dae1f987f3cdbd | |
| parent | 0537943561a37b54467bec19d1b8afbeba8e1e58 (diff) | |
| download | emacs-31ecbf8d513540855aa07588f6746942aed453ba.tar.gz emacs-31ecbf8d513540855aa07588f6746942aed453ba.zip | |
Better decoding of HTML payload in Rmail
lisp/mail/rmailmm.el (rmail-mime-insert-html): Decode HTML payload
when the charset is only given by the HTML <head>, and allow to
specify the encoding with "C-x RET c".
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/mail/rmailmm.el | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b9681d35cf0..1cfd08fc95d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-02-28 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmailmm.el (rmail-mime-insert-html): Decode HTML payload | ||
| 4 | when the charset is only given by the HTML <head>, and allow to | ||
| 5 | specify the encoding with "C-x RET c". | ||
| 6 | |||
| 1 | 2015-02-27 Mark Laws <mdl@60hz.org> | 7 | 2015-02-27 Mark Laws <mdl@60hz.org> |
| 2 | 8 | ||
| 3 | Support daemon mode on MS-Windows (bug#19688) | 9 | Support daemon mode on MS-Windows (bug#19688) |
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index 120d517f55c..00fc25dd440 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el | |||
| @@ -661,6 +661,7 @@ HEADER is a header component of a MIME-entity object (see | |||
| 661 | (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) | 661 | (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) |
| 662 | (charset (cdr (assq 'charset (cdr (rmail-mime-entity-type entity))))) | 662 | (charset (cdr (assq 'charset (cdr (rmail-mime-entity-type entity))))) |
| 663 | (buffer (current-buffer)) | 663 | (buffer (current-buffer)) |
| 664 | (case-fold-search t) | ||
| 664 | coding-system) | 665 | coding-system) |
| 665 | (if charset (setq coding-system (coding-system-from-name charset))) | 666 | (if charset (setq coding-system (coding-system-from-name charset))) |
| 666 | (or (and coding-system (coding-system-p coding-system)) | 667 | (or (and coding-system (coding-system-p coding-system)) |
| @@ -674,6 +675,22 @@ HEADER is a header component of a MIME-entity object (see | |||
| 674 | (ignore-errors (base64-decode-region (point-min) (point-max)))) | 675 | (ignore-errors (base64-decode-region (point-min) (point-max)))) |
| 675 | ((string= transfer-encoding "quoted-printable") | 676 | ((string= transfer-encoding "quoted-printable") |
| 676 | (quoted-printable-decode-region (point-min) (point-max)))) | 677 | (quoted-printable-decode-region (point-min) (point-max)))) |
| 678 | ;; Some broken MUAs state the charset only in the HTML <head>, | ||
| 679 | ;; so if we don't have a non-trivial coding-system at this | ||
| 680 | ;; point, make one last attempt to find it there. | ||
| 681 | (if (eq coding-system 'undecided) | ||
| 682 | (save-excursion | ||
| 683 | (goto-char (point-min)) | ||
| 684 | (when (re-search-forward | ||
| 685 | "^<html><head><meta[^;]*; charset=\\([-a-zA-Z0-9]+\\)" | ||
| 686 | nil t) | ||
| 687 | (setq coding-system (coding-system-from-name (match-string 1))) | ||
| 688 | (or (and coding-system (coding-system-p coding-system)) | ||
| 689 | (setq coding-system 'undecided))) | ||
| 690 | ;; Finally, let them manually force decoding if they know it. | ||
| 691 | (if (and (eq coding-system 'undecided) | ||
| 692 | (not (null coding-system-for-read))) | ||
| 693 | (setq coding-system coding-system-for-read)))) | ||
| 677 | (decode-coding-region (point-min) (point) coding-system) | 694 | (decode-coding-region (point-min) (point) coding-system) |
| 678 | (if (and | 695 | (if (and |
| 679 | (or (not rmail-mime-coding-system) (consp rmail-mime-coding-system)) | 696 | (or (not rmail-mime-coding-system) (consp rmail-mime-coding-system)) |