William Xu <[EMAIL PROTECTED]> writes:

> The problem seems in `nnimap-retrieve-headers'.  The original From field
> is:
>
>     =?gb2312?B?uf638MnM0rXGwMLb?= <[EMAIL PROTECTED]>
>
> but in "*nntpd*" buffer, I got:
>
>     =?GB2312?B?uf638MnM0rXGwMLbIDxuZXdzbGV0dGVyQHRyZW5kYm1hcmtldGluZy5jb20+?=
>
> So, in .gnus when I try to match against
> "<[EMAIL PROTECTED]>", it will fail.

I'm not sure whether this is Gnus imap's fault or gmail's.  Anyway, I
try to decode it properly myself, seems to work for me.  


(defun xwl-base64-decode-from ()
  "Decode \"[EMAIL PROTECTED]" part in address \"Name <[EMAIL PROTECTED]>\".
This function does nothing when \"[EMAIL PROTECTED]" is not base64 encoded."
  (with-current-buffer nntp-server-buffer
    (save-excursion
      (goto-char (point-min))
      (let* ((start (re-search-forward "^From: " nil t 1))
             (end (line-end-position))
             (s (buffer-substring-no-properties start end)))
        (when (string-match "^=\\?.+\\?=$" s)
          (let ((coding (progn (string-match "=\\?\\(.+\\)\\?[bB]\\?" s)
                               (match-string 1 s)))
                (decoded-s (progn (string-match "\\?[bB]\\?\\(.*\\)\\?=" s)
                                  (base64-decode-string (match-string 1 s))))
                (name "")
                (address ""))
            (string-match "\\(.+\\)\\( +<[EMAIL PROTECTED]>?\\)" decoded-s)
            (setq name (match-string 1 decoded-s)
                  address (match-string 2 decoded-s))
            (goto-char start)
            (delete-and-extract-region start end)
            (insert
             (format "=?%s?B?%s?=%s" coding (base64-encode-string name) 
address))))))))

(eval-after-load 'nnimap
  '(progn
     (defadvice nnimap-split-to-groups (before xwl-base64-decode-from activate)
       (xwl-base64-decode-from))
     ))

-- 
William

http://williamxu.net9.org



_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
http://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to