X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=inline;f=eword-decode.el;h=3fca9eda88f03cfc760e679786044ac9490ca955;hb=7a3c95125f4368063bfc2652b19ca47e237543b3;hp=57e23cb6aa00d8fd9d23146fa8edbd39202d21de;hpb=5f818bc644aa9dc0a615224eea1678ac30fd514c;p=elisp%2Fsemi.git diff --git a/eword-decode.el b/eword-decode.el index 57e23cb..3fca9ed 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -10,7 +10,7 @@ ;; Renamed: 1993/06/03 to tiny-mime.el ;; Renamed: 1995/10/03 from tiny-mime.el (split off encoder) ;; Renamed: 1997/02/22 from tm-ew-d.el -;; Version: $Revision: 0.4 $ +;; Version: $Revision: 0.14 $ ;; Keywords: encoded-word, MIME, multilingual, header, mail, news ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). @@ -32,7 +32,6 @@ ;;; Code: -(require 'emu) (require 'std11) (require 'mel) (require 'mime-def) @@ -42,7 +41,7 @@ ;;; (defconst eword-decode-RCS-ID - "$Id: eword-decode.el,v 0.4 1997-02-24 08:51:06 tmorioka Exp $") + "$Id: eword-decode.el,v 0.14 1997-02-27 08:56:45 tmorioka Exp $") (defconst eword-decode-version (get-version-string eword-decode-RCS-ID)) @@ -64,6 +63,43 @@ (regexp-quote "?="))) +;;; @@ Base64 +;;; + +(defconst base64-token-regexp "[A-Za-z0-9+/]") +(defconst base64-token-padding-regexp "[A-Za-z0-9+/=]") + +(defconst eword-B-encoded-text-regexp + (concat "\\(\\(" + base64-token-regexp + base64-token-regexp + base64-token-regexp + base64-token-regexp + "\\)*" + base64-token-regexp + base64-token-regexp + base64-token-padding-regexp + base64-token-padding-regexp + "\\)")) + +;; (defconst eword-B-encoding-and-encoded-text-regexp +;; (concat "\\(B\\)\\?" eword-B-encoded-text-regexp)) + + +;;; @@ Quoted-Printable +;;; + +(defconst quoted-printable-hex-chars "0123456789ABCDEF") +(defconst quoted-printable-octet-regexp + (concat "=[" quoted-printable-hex-chars + "][" quoted-printable-hex-chars "]")) + +(defconst eword-Q-encoded-text-regexp + (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+")) +;; (defconst eword-Q-encoding-and-encoded-text-regexp +;; (concat "\\(Q\\)\\?" eword-Q-encoded-text-regexp)) + + ;;; @ for string ;;; @@ -131,14 +167,13 @@ such as a version of Net$cape)." (replace-match "\\1\\6") (goto-char (point-min)) ) - (let (charset encoding text) - (while (re-search-forward eword-encoded-word-regexp nil t) - (insert (eword-decode-encoded-word - (prog1 - (buffer-substring (match-beginning 0) (match-end 0)) - (delete-region (match-beginning 0) (match-end 0)) - ) must-unfold)) - )) + (while (re-search-forward eword-encoded-word-regexp nil t) + (insert (eword-decode-encoded-word + (prog1 + (buffer-substring (match-beginning 0) (match-end 0)) + (delete-region (match-beginning 0) (match-end 0)) + ) must-unfold)) + ) ))) @@ -176,6 +211,8 @@ If SEPARATOR is not nil, it is used as header separator." ;;; @ encoded-word decoder ;;; +(defvar eword-warning-face nil "Face used for invalid encoded-word.") + (defun eword-decode-encoded-word (word &optional must-unfold) "Decode WORD if it is an encoded-word. @@ -199,11 +236,12 @@ as a version of Net$cape)." (condition-case err (eword-decode-encoded-text charset encoding text must-unfold) (error - (and (tl:add-text-properties 0 (length word) - (and tm:warning-face - (list 'face tm:warning-face)) - word) - word))) + (and + (add-text-properties 0 (length word) + (and eword-warning-face + (list 'face eword-warning-face)) + word) + word))) )) word))