From 2d224ace93275a3171e17ee4dc21f464da262545 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Tue, 27 Sep 2005 15:14:04 +0000 Subject: [PATCH] =?utf8?q?2005-09-27=20=20Arne=20J=C3=B8rgensen=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * message.el (message-remove-duplicates): New function. Implementation borrowed from `gnus-remove-duplicates'. (message-idna-to-ascii-rhs): Also encode idna addresses in Reply-To:, Mail-Reply-To: and Mail-Followup-To:. (message-idna-to-ascii-rhs-1): When `message-use-idna' is 'ask only ask about the same idna domain once per header and also tell in what header to replace the idna domain. * gnus-art.el (article-decode-idna-rhs): Also decode idna addresses in Reply-To:, Mail-Reply-To: and Mail-Followup-To:. (article-decode-idna-rhs): Fix regexp so that all idna-address in a header is decoded and not just the last one. --- lisp/ChangeLog | 15 +++++++++++++++ lisp/gnus-art.el | 8 +++++--- lisp/message.el | 22 +++++++++++++++++----- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f4e53347..b98181b81 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2005-09-27 Arne J,Ax(Brgensen + + * message.el (message-remove-duplicates): New function. + Implementation borrowed from `gnus-remove-duplicates'. + (message-idna-to-ascii-rhs): Also encode idna addresses in + Reply-To:, Mail-Reply-To: and Mail-Followup-To:. + (message-idna-to-ascii-rhs-1): When `message-use-idna' is 'ask + only ask about the same idna domain once per header and also tell + in what header to replace the idna domain. + + * gnus-art.el (article-decode-idna-rhs): Also decode idna + addresses in Reply-To:, Mail-Reply-To: and Mail-Followup-To:. + (article-decode-idna-rhs): Fix regexp so that all idna-address in + a header is decoded and not just the last one. + 2005-09-27 Katsumi Yamaoka * gnus-art.el (gnus-mime-display-single): Don't modify text if it diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index ef675998f..fd97469e1 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -2385,20 +2385,22 @@ If PROMPT (the prefix), prompt for a coding system to use." (autoload 'idna-to-unicode "idna") (defun article-decode-idna-rhs () - "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer." + "Decode IDNA strings in RHS in various headers in current buffer. +The following headers are decoded: From:, To:, Cc:, Reply-To:, +Mail-Reply-To: and Mail-Followup-To:." (when gnus-use-idna (save-restriction (let ((inhibit-point-motion-hooks t) (inhibit-read-only t)) (article-narrow-to-head) (goto-char (point-min)) - (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t) + (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t) (let (ace unicode) (when (save-match-data (and (setq ace (match-string 1)) (save-excursion (and (re-search-backward "^[^ \t]" nil t) - (looking-at "From\\|To\\|Cc"))) + (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To"))) (setq unicode (idna-to-unicode ace)))) (unless (string= ace unicode) (replace-match unicode nil nil nil 1))))))))) diff --git a/lisp/message.el b/lisp/message.el index 7bfcf0acf..df8b0be62 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -2088,6 +2088,14 @@ With prefix-argument just set Follow-Up, don't cross-post." ;;; End of functions adopted from `message-utils.el'. +(defun message-remove-duplicates (list) + (let (new) + (while list + (or (member (car list) new) + (setq new (cons (car list) new))) + (setq list (cdr list))) + (nreverse new))) + (defun message-remove-header (header &optional is-regexp first reverse) "Remove HEADER in the narrowed buffer. If IS-REGEXP, HEADER is a regular expression. @@ -5027,13 +5035,15 @@ subscribed address (and not the additional To and Cc header contents)." (let ((field (message-fetch-field header)) rhs ace address) (when field - (dolist (address (mail-header-parse-addresses field)) - (setq address (car address) - rhs (downcase (or (cadr (split-string address "@")) "")) - ace (downcase (idna-to-ascii rhs))) + (dolist (rhs + (message-remove-duplicates + (mapcar (lambda (rhs) (or (cadr (split-string rhs "@")) "")) + (mapcar 'downcase + (mapcar 'car (mail-header-parse-addresses field)))))) + (setq ace (downcase (idna-to-ascii rhs))) (when (and (not (equal rhs ace)) (or (not (eq message-use-idna 'ask)) - (y-or-n-p (format "Replace %s with %s? " rhs ace)))) + (y-or-n-p (format "Replace %s with %s in %s:? " rhs ace header)))) (goto-char (point-min)) (while (re-search-forward (concat "^" header ":") nil t) (message-narrow-to-field) @@ -5053,6 +5063,8 @@ See `message-idna-encode'." (message-idna-to-ascii-rhs-1 "From") (message-idna-to-ascii-rhs-1 "To") (message-idna-to-ascii-rhs-1 "Reply-To") + (message-idna-to-ascii-rhs-1 "Mail-Reply-To") + (message-idna-to-ascii-rhs-1 "Mail-Followup-To") (message-idna-to-ascii-rhs-1 "Cc"))))) (defun message-generate-headers (headers) -- 2.25.1