>>>> "VS" == Ville Skyttä
<scop(a)xemacs.org> writes:
VS> On Tue, 2002-11-19 at 02:08, Martin Schwenke wrote:
> There's a mismatch in logic between sc-get-address and
> sc-attribs-extract-namestring in supercite.el. I receive e-mail from
> a someone who's From: address looks like:
>
> Doe John x1234 <john(a)doe.a.deer>
VS> [...]
VS> Looks good to me Martin. Could you send a patch?
It gets worse! I also get e-mail from someone who's From: address
looks like:
"J.Doe" <john(a)doe.a.deer>
Note the lack of space. sc-attribs-extract-namestring returns
"J. Doe", which is fair enough. However, when sc-get-address doesn't
find this at the beginning of the from address, it grabs the string
matched by
((string-match "[-+a-zA-Z0-9!(a)%._]+" from)
which is "J.Doe", which definitely isn't an address! A dumb fix is to
do something like
(string-match "[-+a-zA-Z0-9!@%._]+[!@%][-+a-zA-Z0-9!(a)%._]+" from)
so that it grabs a string that has at least one important e-mail
separator in it.
I'm guessing there's some history here, but surely mail-extr.el should
be the place where this logic lives, not supercite.el? Does anyone
know why sc-get-address's first attempt at getting the address doesn't
simply do:
(let ((from-parts (mail-extract-address-components from)))
(or (cadr from-parts)
...
Adding this to the beginning of supercite.el/sc-get-address fixes both
of my problems. A patch follows at the end - note that I've removed
my previous fix, since it isn't necessary - if someone can check what
mail-extract-address-components does on a "Motorola X.400
non-prettified address", then we might be able to chuck most of the
rubbish in that function away...
If this looks like a good fix then I'll provide a patch to the
ChangeLog too and post to xemacs-patches... if you don't just apply
it...
peace & happiness,
martin
*** supercite.el 2002/11/22 05:16:37 1.1
--- supercite.el 2002/11/22 05:17:08
***************
*** 1038,1057 ****
AUTHOR is the author's name (which is removed from the address)."
(when (fboundp sc-rewrite-address-function)
(setq from (funcall sc-rewrite-address-function from)))
! (let ((eos (length from)))
! (if (string-match (concat "\\(^\\|^\"\\)" author
! "\\(\\s +\\|\"\\s +\\)") from 0)
! (let ((address (substring from (match-end 0) eos)))
! (if (and (= (aref address 0) ?<)
! (= (aref address (1- (length address))) ?>))
! (substring address 1 (1- (length address)))
! address))
! (cond ((string-match
"/[GS]=\\([-a-zA-Z0-9._]+\\)[^!@%]+\\([-a-zA-Z0-9!(a)%._]+\\)" from)
! ;; Motorola X.400 non-prettified address
! (concat (sc-submatch 1 from) (sc-submatch 2 from)))
! ((string-match "[-+a-zA-Z0-9!(a)%._]+" from)
! (sc-submatch 0 from))
! (t "")))))
(defun sc-attribs-emailname (from)
"Get the email terminus name from FROM."
--- 1038,1059 ----
AUTHOR is the author's name (which is removed from the address)."
(when (fboundp sc-rewrite-address-function)
(setq from (funcall sc-rewrite-address-function from)))
! (let ((from-parts (mail-extract-address-components from)))
! (or (cadr from-parts)
! (let ((eos (length from)))
! (if (string-match (concat "\\(^\\|^\"\\)" author
! "\\(\\s +\\|\"\\s +\\)") from 0)
! (let ((address (substring from (match-end 0) eos)))
! (if (and (= (aref address 0) ?<)
! (= (aref address (1- (length address))) ?>))
! (substring address 1 (1- (length address)))
! address))
! (cond ((string-match
"/[GS]=\\([-a-zA-Z0-9._]+\\)[^!@%]+\\([-a-zA-Z0-9!(a)%._]+\\)" from)
! ;; Motorola X.400 non-prettified address
! (concat (sc-submatch 1 from) (sc-submatch 2 from)))
! ((string-match "[-+a-zA-Z0-9!(a)%._]+" from)
! (sc-submatch 0 from))
! (t "")))))))
(defun sc-attribs-emailname (from)
"Get the email terminus name from FROM."