[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nnimap: splitting against From doesn't always work

From: William Xu
Subject: Re: nnimap: splitting against From doesn't always work
Date: Sat, 19 Apr 2008 14:40:18 +0900
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin)

William Xu <> writes:

> The problem seems in `nnimap-retrieve-headers'.  The original From field
> is:
>     =?gb2312?B?uf638MnM0rXGwMLb?= <>
> but in "*nntpd*" buffer, I got:
>     =?GB2312?B?uf638MnM0rXGwMLbIDxuZXdzbGV0dGVyQHRyZW5kYm1hcmtldGluZy5jb20+?=
> So, in .gnus when I try to match against
> "<>", 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 \"foo@bar\" part in address \"Name <foo@bar>\".
This function does nothing when \"foo@bar\" is not base64 encoded."
  (with-current-buffer nntp-server-buffer
      (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 "\\(.+\\)\\( +<?.+@.+>?\\)" decoded-s)
            (setq name (match-string 1 decoded-s)
                  address (match-string 2 decoded-s))
            (goto-char start)
            (delete-and-extract-region start end)
             (format "=?%s?B?%s?=%s" coding (base64-encode-string name) 

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]