Mercurial > hg > xemacs-beta
comparison lisp/tm/tm-ew-d.el @ 74:54cc21c15cbb r20-0b32
Import from CVS: tag r20-0b32
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:04:33 +0200 |
parents | 131b0175ea99 |
children | 1ce6082ce73f |
comparison
equal
deleted
inserted
replaced
73:e2d7a37b7c8d | 74:54cc21c15cbb |
---|---|
1 ;;; tm-ew-d.el --- RFC 1522 based MIME encoded-word decoder for GNU Emacs | 1 ;;; tm-ew-d.el --- RFC 2047 based encoded-word decoder for GNU Emacs |
2 | 2 |
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: ENAMI Tsugutomo <enami@sys.ptg.sony.co.jp> | 5 ;; Author: ENAMI Tsugutomo <enami@sys.ptg.sony.co.jp> |
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> | 6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> |
7 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp> | 7 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp> |
8 ;; Created: 1995/10/03 | 8 ;; Created: 1995/10/03 |
9 ;; Original: 1992/07/20 ENAMI Tsugutomo's `mime.el'. | 9 ;; Original: 1992/07/20 ENAMI Tsugutomo's `mime.el'. |
10 ;; Renamed: 1993/06/03 to tiny-mime.el. | 10 ;; Renamed: 1993/06/03 to tiny-mime.el. |
11 ;; Renamed: 1995/10/03 from tiny-mime.el. (split off encoder) | 11 ;; Renamed: 1995/10/03 from tiny-mime.el. (split off encoder) |
12 ;; Version: $Revision: 1.1.1.1 $ | 12 ;; Version: $Revision: 1.1.1.2 $ |
13 ;; Keywords: mail, news, MIME, RFC 1522, multilingual, encoded-word | 13 ;; Keywords: encoded-word, MIME, multilingual, header, mail, news |
14 | 14 |
15 ;; This file is part of tm (Tools for MIME). | 15 ;; This file is part of tm (Tools for MIME). |
16 | 16 |
17 ;; This program is free software; you can redistribute it and/or | 17 ;; This program is free software; you can redistribute it and/or |
18 ;; modify it under the terms of the GNU General Public License as | 18 ;; modify it under the terms of the GNU General Public License as |
39 | 39 |
40 ;;; @ version | 40 ;;; @ version |
41 ;;; | 41 ;;; |
42 | 42 |
43 (defconst tm-ew-d/RCS-ID | 43 (defconst tm-ew-d/RCS-ID |
44 "$Id: tm-ew-d.el,v 1.1.1.1 1996/12/18 22:43:37 steve Exp $") | 44 "$Id: tm-ew-d.el,v 1.1.1.2 1996/12/21 20:50:42 steve Exp $") |
45 (defconst mime/eword-decoder-version (get-version-string tm-ew-d/RCS-ID)) | 45 (defconst mime/eword-decoder-version (get-version-string tm-ew-d/RCS-ID)) |
46 | 46 |
47 | 47 |
48 ;;; @ MIME encoded-word definition | 48 ;;; @ MIME encoded-word definition |
49 ;;; | 49 ;;; |
120 (narrow-to-region start end) | 120 (narrow-to-region start end) |
121 (if unfolding | 121 (if unfolding |
122 (mime/unfolding) | 122 (mime/unfolding) |
123 ) | 123 ) |
124 (goto-char (point-min)) | 124 (goto-char (point-min)) |
125 (while (re-search-forward | 125 (while (re-search-forward "\\?=\\(\n*\\s +\\)+=\\?" nil t) |
126 (concat (regexp-quote "?=") "\\s +" (regexp-quote "=?")) | |
127 nil t) | |
128 (replace-match "?==?") | 126 (replace-match "?==?") |
129 ) | 127 ) |
130 (goto-char (point-min)) | 128 (goto-char (point-min)) |
131 (let (charset encoding text) | 129 (let (charset encoding text) |
132 (while (re-search-forward mime/encoded-word-regexp nil t) | 130 (while (re-search-forward mime/encoded-word-regexp nil t) |
155 (defun mime/unfolding () | 153 (defun mime/unfolding () |
156 (goto-char (point-min)) | 154 (goto-char (point-min)) |
157 (let (field beg end) | 155 (let (field beg end) |
158 (while (re-search-forward std11-field-head-regexp nil t) | 156 (while (re-search-forward std11-field-head-regexp nil t) |
159 (setq beg (match-beginning 0) | 157 (setq beg (match-beginning 0) |
160 end (std11-field-end)) | 158 end (std11-field-end)) |
161 (setq field (buffer-substring beg end)) | 159 (setq field (buffer-substring beg end)) |
162 (if (string-match mime/encoded-word-regexp field) | 160 (if (string-match mime/encoded-word-regexp field) |
163 (save-restriction | 161 (save-restriction |
164 (narrow-to-region (goto-char beg) end) | 162 (narrow-to-region (goto-char beg) end) |
165 (while (re-search-forward "\n[ \t]+" nil t) | 163 (while (re-search-forward "\n\\([ \t]\\)" nil t) |
166 (replace-match " ") | 164 (replace-match |
167 ) | 165 (match-string 1)) |
166 ) | |
168 (goto-char (point-max)) | 167 (goto-char (point-max)) |
169 )) | 168 )) |
170 ))) | 169 ))) |
171 | 170 |
172 | 171 |
191 (substring word (match-beginning 2) (match-end 2)) | 190 (substring word (match-beginning 2) (match-end 2)) |
192 )) | 191 )) |
193 (text | 192 (text |
194 (substring word (match-beginning 3) (match-end 3)) | 193 (substring word (match-beginning 3) (match-end 3)) |
195 )) | 194 )) |
196 (mime/decode-encoded-text charset encoding text must-unfold) | 195 (condition-case err |
196 (mime/decode-encoded-text charset encoding text must-unfold) | |
197 (error nil)) | |
197 )) | 198 )) |
198 word)) | 199 word)) |
199 | 200 |
200 | 201 |
201 ;;; @ encoded-text decoder | 202 ;;; @ encoded-text decoder |
213 if there are in decoded encoded-text (generated by bad manner MUA such | 214 if there are in decoded encoded-text (generated by bad manner MUA such |
214 as a version of Net$cape). [tm-ew-d.el]" | 215 as a version of Net$cape). [tm-ew-d.el]" |
215 (let ((cs (mime-charset-to-coding-system charset))) | 216 (let ((cs (mime-charset-to-coding-system charset))) |
216 (if cs | 217 (if cs |
217 (let ((dest | 218 (let ((dest |
218 (cond ((string-equal "B" encoding) | 219 (cond ((and (string-equal "B" encoding) |
219 (base64-decode-string string)) | 220 (string-match mime/B-encoded-text-regexp string)) |
220 ((string-equal "Q" encoding) | 221 (base64-decode-string string)) |
221 (q-encoding-decode-string string)) | 222 ((and (string-equal "Q" encoding) |
222 (t (message "unknown encoding %s" encoding) | 223 (string-match mime/Q-encoded-text-regexp string)) |
224 (q-encoding-decode-string string)) | |
225 (t (message "Invalid encoded-word %s" encoding) | |
223 nil)))) | 226 nil)))) |
224 (if dest | 227 (if dest |
225 (progn | 228 (progn |
226 (setq dest (decode-coding-string dest cs)) | 229 (setq dest (decode-coding-string dest cs)) |
227 (if must-unfold | 230 (if must-unfold |