diff options
| author | Karl Heuer | 1997-12-04 04:32:03 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-12-04 04:32:03 +0000 |
| commit | 36347d4342355ee31b9d4237503d2b43c8e57e2d (patch) | |
| tree | 5a62412e8837c3d8e9fcca9595f634c2c2b68f60 | |
| parent | fc4d62fe1ba210f4f21c0345b791a0fb60c75b41 (diff) | |
| download | emacs-36347d4342355ee31b9d4237503d2b43c8e57e2d.tar.gz emacs-36347d4342355ee31b9d4237503d2b43c8e57e2d.zip | |
(rmail-decode-quoted-printable): New function
mostly copied from gnus-art.el.
(rmail-hex-string-to-integer): New fn, copied from hexl.el.
(rmail-hex-char-to-integer): Likewise.
(rmail-convert-to-babyl-format): Use rmail-decode-quoted-printable.
| -rw-r--r-- | lisp/mail/rmail.el | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 4ca92b13275..e9d6243a128 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -1478,10 +1478,7 @@ Optional DEFAULT is password to start with." | |||
| 1478 | (setq count (1+ count)) | 1478 | (setq count (1+ count)) |
| 1479 | (if quoted-printable-header-field-end | 1479 | (if quoted-printable-header-field-end |
| 1480 | (save-excursion | 1480 | (save-excursion |
| 1481 | (save-restriction | 1481 | (rmail-decode-quoted-printable header-end (point)) |
| 1482 | (narrow-to-region header-end (point)) | ||
| 1483 | (require 'gnus-art) | ||
| 1484 | (article-mime-decode-quoted-printable-buffer)) | ||
| 1485 | ;; Change "quoted-printable" to "8bit", | 1482 | ;; Change "quoted-printable" to "8bit", |
| 1486 | ;; to reflect the decoding we just did. | 1483 | ;; to reflect the decoding we just did. |
| 1487 | (goto-char quoted-printable-header-field-end) | 1484 | (goto-char quoted-printable-header-field-end) |
| @@ -1508,6 +1505,46 @@ Optional DEFAULT is password to start with." | |||
| 1508 | (t (error "Cannot convert to babyl format"))))) | 1505 | (t (error "Cannot convert to babyl format"))))) |
| 1509 | count)) | 1506 | count)) |
| 1510 | 1507 | ||
| 1508 | (defun rmail-hex-char-to-integer (character) | ||
| 1509 | "Return CHARACTER's value interpreted as a hex digit." | ||
| 1510 | (if (and (>= character ?0) (<= character ?9)) | ||
| 1511 | (- character ?0) | ||
| 1512 | (let ((ch (logior character 32))) | ||
| 1513 | (if (and (>= ch ?a) (<= ch ?f)) | ||
| 1514 | (- ch (- ?a 10)) | ||
| 1515 | (error "Invalid hex digit `%c'" ch))))) | ||
| 1516 | |||
| 1517 | (defun rmail-hex-string-to-integer (hex-string) | ||
| 1518 | "Return decimal integer for HEX-STRING." | ||
| 1519 | (let ((hex-num 0) | ||
| 1520 | (index 0)) | ||
| 1521 | (while (< index (length hex-string)) | ||
| 1522 | (setq hex-num (+ (* hex-num 16) | ||
| 1523 | (rmail-hex-char-to-integer (aref hex-string index)))) | ||
| 1524 | (setq index (1+ index))) | ||
| 1525 | hex-num)) | ||
| 1526 | |||
| 1527 | (defun rmail-decode-quoted-printable (from to) | ||
| 1528 | "Decode Quoted-Printable in the region between FROM and TO." | ||
| 1529 | (interactive "r") | ||
| 1530 | (goto-char from) | ||
| 1531 | (or (markerp to) | ||
| 1532 | (setq to (copy-marker to))) | ||
| 1533 | (while (search-forward "=" to t) | ||
| 1534 | (cond ((eq (following-char) ?\n) | ||
| 1535 | (delete-char -1) | ||
| 1536 | (delete-char 1)) | ||
| 1537 | ((looking-at "[0-9A-F][0-9A-F]") | ||
| 1538 | (subst-char-in-region | ||
| 1539 | (1- (point)) (point) ?= | ||
| 1540 | (rmail-hex-string-to-integer | ||
| 1541 | (buffer-substring (point) (+ 2 (point))))) | ||
| 1542 | (delete-char 2)) | ||
| 1543 | ((looking-at "=") | ||
| 1544 | (delete-char 1)) | ||
| 1545 | (t | ||
| 1546 | (message "Malformed MIME quoted-printable message"))))) | ||
| 1547 | |||
| 1511 | ;; Delete the "From ..." line, creating various other headers with | 1548 | ;; Delete the "From ..." line, creating various other headers with |
| 1512 | ;; information from it if they don't already exist. Now puts the | 1549 | ;; information from it if they don't already exist. Now puts the |
| 1513 | ;; original line into a mail-from: header line for debugging and for | 1550 | ;; original line into a mail-from: header line for debugging and for |