flim-1_14-rfc2231-encoder
Shuhei KOBAYASHI
shuhei @ aqua.ocn.ne.jp
2002年 6月 7日 (金) 23:34:44 JST
少し前のことですが, flim-1_14-rfc2231-encoder branch が作成されました.
;; m17n の cvs-info watchers に発見されることを期待していたのですが...
現状の問題点は extended-parameter に比べると regular-parameter の分割が
少し手抜きであること(この辺は私のせい)と, field-body が US-ASCII のみの
場合は mime-encode-header-in-buffer が素通ししてしまうので encoder には
渡らない(これは message/external-body の URL parameter などで問題になる)
ということです.
後者については, 岡田さんによる mime-header-encode-method-alist の導入前
ならば, mime-encode-header-in-buffer から以下のように US-ASCII の判定を
なくした上で
(defun mime-encode-header-in-buffer (&optional code-conversion)
"Encode header fields to network representation, such as MIME encoded-word.
It refer variable `mime-field-encoding-method-alist'."
(interactive "*")
(save-excursion
(save-restriction
(std11-narrow-to-header mail-header-separator)
(goto-char (point-min))
(let ((default-cs (mime-charset-to-coding-system default-mime-charset))
beg end field-name)
(while (re-search-forward std11-field-head-regexp nil t)
(setq beg (match-end 0)
field-name (buffer-substring (match-beginning 0) (1- beg))
end (std11-field-end))
(let ((method (eword-find-field-encoding-method field-name)))
(cond ((eq method 'mime)
(insert
(prog1
(mime-encode-field-body
(buffer-substring beg end)
field-name)
(delete-region beg end))))
(code-conversion
(encode-coding-region
beg end
(or (mime-charset-to-coding-system method)
default-cs))))))))))
mime-encode-field-body の途中にその判定を移すという手を考えたのですが,
(defun mime-encode-field-body (field-body field-name)
"Encode FIELD-BODY as FIELD-NAME, and return the result.
A lexical token includes non-ASCII character is encoded as MIME
encoded-word. ASCII token is not encoded."
(setq field-body (std11-unfold-string field-body))
(if (string= field-body "")
""
(let (start)
(if (symbolp field-name)
(setq start (1+ (length (symbol-name field-name))))
(setq start (1+ (length field-name))
field-name (intern (capitalize field-name))))
(cond ((eq field-name 'Content-Type)
(eword-encode-Content-Type-field-body field-body start))
((eq field-name 'Content-Disposition)
(eword-encode-Content-Disposition-field-body field-body start))
((null (find-non-ascii-charset-string field-body))
field-body)
((memq field-name
'(Reply-To
From Sender
Resent-Reply-To Resent-From
Resent-Sender To Resent-To
Cc Resent-Cc Bcc Resent-Bcc
Dcc))
(eword-encode-address-list field-body start))
((eq field-name 'In-Reply-To)
(eword-encode-in-reply-to field-body start))
((memq field-name '(Mime-Version User-Agent))
(eword-encode-structured-field-body field-body start))
(t
(eword-encode-unstructured-field-body field-body start))))))
mime-header-encode-method-alist には各 field に対する encoder を手軽に
変更できるという利点があるので, (mime-field-encoding-method-alist も
含めて?)この辺は見直した方が良いような気がします.
;; mime-field-encoding-method-alist の docstring は実装と合っていない.
--
Shuhei KOBAYASHI
More information about the Emacs-mime-ja
mailing list