aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-10-03 16:13:36 +0000
committerDave Love2000-10-03 16:13:36 +0000
commit657b2c659bf14036ca9cc5c8b167b737eb995bac (patch)
treeb6585e6c19642d66b4b9a6e20b6f59383f15c92c
parent72fc04186ab21d555fd993fbab1971a8a8bd0c72 (diff)
downloademacs-657b2c659bf14036ca9cc5c8b167b737eb995bac.tar.gz
emacs-657b2c659bf14036ca9cc5c8b167b737eb995bac.zip
Don't require mm-util.
(quoted-printable-decode-region): Rewritten. (quoted-printable-decode-string, quoted-printable-encode-region): Doc fix. (quoted-printable-encode-region): Barf on multibyte characters. Maybe make the class multibyte. Upcase chars, not formatted strings. Allow mm-use-ultra-safe-encoding to be unbound. (quoted-printable-encode-string): Don't use mm-with-unibyte-buffer.
-rw-r--r--lisp/gnus/ChangeLog29
-rw-r--r--lisp/gnus/qp.el157
2 files changed, 109 insertions, 77 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index ae52c27e7d9..182c9685f82 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,27 @@
12000-10-03 Dave Love <fx@gnu.org>
2
3 * mail-source.el (mail-sources): Revert to nil.
4
5 * qp.el: Don't require mm-util.
6 (quoted-printable-decode-region): Rewritten.
7 (quoted-printable-decode-string, quoted-printable-encode-region):
8 Doc fix.
9 (quoted-printable-encode-region): Barf on multibyte characters.
10 Maybe make the class multibyte. Upcase chars, not formatted
11 strings. Allow mm-use-ultra-safe-encoding to be unbound.
12 (quoted-printable-encode-string): Don't use
13 mm-with-unibyte-buffer.
14
152000-10-03 ShengHuo ZHU <zsh@cs.rochester.edu>
16
17 * mail-source.el (mail-source-report-new-mail): Use
18 nnheader-cancel-timer.
19
202000-10-03 Simon Josefsson <simon@josefsson.org>
21
22 * mail-source.el (mail-source-imap-file-coding-system): New variable.
23 (mail-source-fetch-imap): Use it.
24
12000-09-29 Gerd Moellmann <gerd@gnu.org> 252000-09-29 Gerd Moellmann <gerd@gnu.org>
2 26
3 * gnus.el (gnus-mode-line-buffer-identification)[EMACS]: Fix 27 * gnus.el (gnus-mode-line-buffer-identification)[EMACS]: Fix
@@ -16,6 +40,11 @@
16 40
172000-09-21 Dave Love <fx@gnu.org> 412000-09-21 Dave Love <fx@gnu.org>
18 42
43 * smiley-ems.el (smiley-region): Test if display-graphic-p bound
44 (for Emacs 20). Tidy somewhat.
45
462000-09-21 Dave Love <fx@gnu.org>
47
19 * gnus-ems.el (gnus-article-display-xface): Use unibyte for the 48 * gnus-ems.el (gnus-article-display-xface): Use unibyte for the
20 image processing. Rationalize logic somewhat. 49 image processing. Rationalize logic somewhat.
21 50
diff --git a/lisp/gnus/qp.el b/lisp/gnus/qp.el
index ea2a81836fa..5bfb149bf69 100644
--- a/lisp/gnus/qp.el
+++ b/lisp/gnus/qp.el
@@ -1,7 +1,10 @@
1;;; qp.el --- Quoted-Printable functions 1;;; qp.el --- Quoted-Printable functions
2
2;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. 3;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 4
4;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> 5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6;; Keywords: mail, extensions
7
5;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
6 9
7;; GNU Emacs is free software; you can redistribute it and/or modify 10;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -21,61 +24,51 @@
21 24
22;;; Commentary: 25;;; Commentary:
23 26
24;;; Code: 27;; Functions for encoding and decoding quoted-printable text as
25 28;; defined in RFC 2045.
26(require 'mm-util)
27 29
28(defvar quoted-printable-encoding-characters 30;;; Code:
29 (mapcar 'identity "0123456789ABCDEFabcdef"))
30 31
31(defun quoted-printable-decode-region (from to &optional charset) 32(defun quoted-printable-decode-region (from to &optional charset)
32 "Decode quoted-printable in the region between FROM and TO. 33 "Decode quoted-printable in the region between FROM and TO, per RFC 2045.
33If CHARSET is non-nil, decode the region with charset." 34If CHARSET is non-nil, decode bytes into characters with that charset."
34 (interactive "r") 35 (interactive "r")
35 (save-excursion 36 (save-excursion
36 (save-restriction 37 (save-restriction
37 (let (start) 38 (let ((nonascii-insert-offset nonascii-insert-offset)
39 ;; RFC 2045: An "=" followed by two hexadecimal digits,
40 ;; one or both of which are lowercase letters in "abcdef",
41 ;; is formally illegal. A robust implementation might
42 ;; choose to recognize them as the corresponding uppercase
43 ;; letters.
44 (case-fold-search t))
45 (if charset
46 (setq nonascii-insert-offset (- (make-char charset) 128)))
38 (narrow-to-region from to) 47 (narrow-to-region from to)
39 (goto-char from) 48 (goto-char from)
40 (while (not (eobp)) 49 (while (and (skip-chars-forward "^=" to)
41 (cond 50 (not (eobp)))
42 ((eq (char-after) ?=) 51 (cond ((eq (char-after (1+ (point))) ?\n)
43 (delete-char 1) 52 (delete-char 2))
44 (unless start 53 ((looking-at "=[0-9A-F][0-9A-F]")
45 (setq start (point))) 54 (let ((byte (string-to-int (buffer-substring (1+ (point))
46 (cond 55 (+ 3 (point)))
47 ;; End of the line. 56 16)))
48 ((eq (char-after) ?\n) 57 (if (and charset (fboundp 'unibyte-char-to-multibyte))
49 (delete-char 1)) 58 (insert (unibyte-char-to-multibyte byte))
50 ;; Encoded character. 59 (insert byte))
51 ((and 60 (delete-region (point) (+ 3 (point)))
52 (memq (char-after) quoted-printable-encoding-characters) 61 (unless (eq byte ?=)
53 (memq (char-after (1+ (point))) 62 (backward-char))))
54 quoted-printable-encoding-characters)) 63 ((eq (char-after (1+ (point))) ?=)
55 (insert 64 (forward-char)
56 (string-to-number 65 (delete-char 1))
57 (buffer-substring (point) (+ 2 (point))) 66 (t
58 16)) 67 (message "Malformed MIME quoted-printable message")
59 (delete-char 2)) 68 (forward-char))))))))
60 ;; Quoted equal sign.
61 ((eq (char-after) ?=)
62 (forward-char 1))
63 ;; End of buffer.
64 ((eobp))
65 ;; Invalid.
66 (t
67 (message "Malformed MIME quoted-printable message"))))
68 ((and charset start (not (eq (mm-charset-after) 'ascii)))
69 (mm-decode-coding-region start (point) charset)
70 (setq start nil)
71 (forward-char 1))
72 (t
73 (forward-char 1))))
74 (if (and charset start)
75 (mm-decode-coding-region start (point) charset))))))
76 69
77(defun quoted-printable-decode-string (string &optional charset) 70(defun quoted-printable-decode-string (string &optional charset)
78 "Decode the quoted-printable-encoded STRING and return the results. 71 "Decode the quoted-printable encoded STRING and return the result.
79If CHARSET is non-nil, decode the region with charset." 72If CHARSET is non-nil, decode the region with charset."
80 (with-temp-buffer 73 (with-temp-buffer
81 (insert string) 74 (insert string)
@@ -83,26 +76,33 @@ If CHARSET is non-nil, decode the region with charset."
83 (buffer-string))) 76 (buffer-string)))
84 77
85(defun quoted-printable-encode-region (from to &optional fold class) 78(defun quoted-printable-encode-region (from to &optional fold class)
86 "QP-encode the region between FROM and TO. 79 "Quoted-printable encode the region between FROM and TO per RFC 2045.
87 80
88If FOLD fold long lines. If CLASS, translate the characters 81If FOLD, fold long lines at 76 characters (as required by the RFC).
89matched by that regexp. 82If CLASS is non-nil, translate the characters matched by that class in
83the form expected by `skip-chars-forward'.
90 84
91If `mm-use-ultra-safe-encoding' is set, fold unconditionally and 85If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and
92encode lines starting with \"From\"." 86encode lines starting with \"From\"."
93 (interactive "r") 87 (interactive "r")
88 (if (delq 'eight-bit-graphic
89 (delq 'eight-bit-control
90 (delq 'ascii (mm-find-charset-region from to))))
91 (error "Multibyte character in QP encoding region"))
92 (unless class
93 (setq class "^\000-\007\013\015-\037\200-\377="))
94 (if (fboundp 'string-as-multibyte)
95 (setq class (string-as-multibyte class)))
94 (save-excursion 96 (save-excursion
95 (save-restriction 97 (save-restriction
96 (narrow-to-region from to) 98 (narrow-to-region from to)
97 ;; (mm-encode-body)
98 ;; Encode all the non-ascii and control characters. 99 ;; Encode all the non-ascii and control characters.
99 (goto-char (point-min)) 100 (goto-char (point-min))
100 (while (and (skip-chars-forward 101 (while (and (skip-chars-forward class)
101 (or class "^\000-\007\013\015-\037\200-\377="))
102 (not (eobp))) 102 (not (eobp)))
103 (insert 103 (insert
104 (prog1 104 (prog1
105 (upcase (format "=%02x" (char-after))) 105 (format "=%02x" (upcase (char-after)))
106 (delete-char 1)))) 106 (delete-char 1))))
107 ;; Encode white space at the end of lines. 107 ;; Encode white space at the end of lines.
108 (goto-char (point-min)) 108 (goto-char (point-min))
@@ -111,36 +111,39 @@ encode lines starting with \"From\"."
111 (while (not (eolp)) 111 (while (not (eolp))
112 (insert 112 (insert
113 (prog1 113 (prog1
114 (upcase (format "=%02x" (char-after))) 114 (format "=%02x" (upcase (char-after)))
115 (delete-char 1))))) 115 (delete-char 1)))))
116 (when (or fold mm-use-ultra-safe-encoding) 116 (let ((mm-use-ultra-safe-encoding
117 ;; Fold long lines. 117 (and (boundp 'mm-use-ultra-safe-encoding)
118 (let ((tab-width 1)) ;; HTAB is one character. 118 mm-use-ultra-safe-encoding)))
119 (goto-char (point-min)) 119 (when (or fold mm-use-ultra-safe-encoding)
120 (while (not (eobp)) 120 ;; Fold long lines.
121 ;; In ultra-safe mode, encode "From " at the beginning of a 121 (let ((tab-width 1)) ; HTAB is one character.
122 ;; line. 122 (goto-char (point-min))
123 (when mm-use-ultra-safe-encoding 123 (while (not (eobp))
124 (beginning-of-line) 124 ;; In ultra-safe mode, encode "From " at the beginning
125 (when (looking-at "From ") 125 ;; of a line.
126 (replace-match "From=20" nil t))) 126 (when mm-use-ultra-safe-encoding
127 (end-of-line) 127 (beginning-of-line)
128 (while (> (current-column) 76) ;; tab-width must be 1. 128 (when (looking-at "From ")
129 (beginning-of-line) 129 (replace-match "From=20" nil t)))
130 (forward-char 75);; 75 chars plus an "=" 130 (end-of-line)
131 (search-backward "=" (- (point) 2) t) 131 (while (> (current-column) 76) ; tab-width must be 1.
132 (insert "=\n") 132 (beginning-of-line)
133 (end-of-line)) 133 (forward-char 75) ; 75 chars plus an "="
134 (unless (eobp) 134 (search-backward "=" (- (point) 2) t)
135 (forward-line)))))))) 135 (insert "=\n")
136 (end-of-line))
137 (unless (eobp)
138 (forward-line)))))))))
136 139
137(defun quoted-printable-encode-string (string) 140(defun quoted-printable-encode-string (string)
138 "QP-encode STRING and return the results." 141 "Encode the STRING as quoted-printable and return the result."
139 (mm-with-unibyte-buffer 142 (with-temp-buffer
140 (insert string) 143 (insert string)
141 (quoted-printable-encode-region (point-min) (point-max)) 144 (quoted-printable-encode-region (point-min) (point-max))
142 (buffer-string))) 145 (buffer-string)))
143 146
144(provide 'qp) 147(provide 'qp)
145 148
146;; qp.el ends here 149;;; qp.el ends here