From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/61020 Path: news.gmane.org!not-for-mail From: Arne =?iso-8859-1?Q?J=F8rgensen?= Newsgroups: gmane.emacs.gnus.general Subject: Other IDN-fixes (was: Hashcash-generation/check for IDN-domains) Date: Tue, 27 Sep 2005 16:29:09 +0200 Organization: Arne Joergensen -- http://arnested.dk/ Message-ID: <87slvqvb2i.fsf@arnested.dk> References: <87y85iejat.fsf@koldfront.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1127832184 20326 80.91.229.2 (27 Sep 2005 14:43:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Sep 2005 14:43:04 +0000 (UTC) Original-X-From: ding-owner+m9552@lists.math.uh.edu Tue Sep 27 16:43:01 2005 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EKGcT-0001NH-Ir for ding-account@gmane.org; Tue, 27 Sep 2005 16:39:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1EKGcP-0002Mb-00; Tue, 27 Sep 2005 09:39:41 -0500 Original-Received: from nas02.math.uh.edu ([129.7.128.40]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1EKGZP-0002MV-00 for ding@lists.math.uh.edu; Tue, 27 Sep 2005 09:36:35 -0500 Original-Received: from quimby.gnus.org ([80.91.224.244]) by nas02.math.uh.edu with esmtp (Exim 4.52) id 1EKGZI-00046x-Rx for ding@lists.math.uh.edu; Tue, 27 Sep 2005 09:36:35 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1EKGZH-0008Qs-00 for ; Tue, 27 Sep 2005 16:36:27 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EKGVc-0006eJ-1r for ding@gnus.org; Tue, 27 Sep 2005 16:32:40 +0200 Original-Received: from 213.237.94.152 ([213.237.94.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Sep 2005 16:32:39 +0200 Original-Received: from arne by 213.237.94.152 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Sep 2005 16:32:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Lines: 161 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 213.237.94.152 X-Face: 5t,7/Y$&<1A_t.$vC2{pWZ{m@3_06;kcm]no{hgEL/}Uz(>XV6cl4}xO\v?-h3%>znNaZtq `~rf,GY1T%r=a.zH`hOb(-]'x)nI088Z&|e;V^h;/TShou User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:3RIp63UoCNhOz/YG/WSgz/fl86g= X-Spam-Score: -1.3 (-) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:61020 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit asjo@koldfront.dk (Adam Sjøgren) writes: > I (sort-of) recently acquired the domain 'sjøgren.org'. > > I just tried sending an email to adam@sjøgren.org - Gnus nicely asked > me if it should translate sjøgren.org to xn--sjgren-cya.org, and I > happily accepted. Your posting just reminded me that I've had and used some fixes for the IDN-handling for some weeks now (since i bought jøssen.dk). The patch doesn't solve your problem as far as I can tell. It fixes the following things though: 1. Decoding articles with more than one IDN-address in the same field (i.e. "To: adam@sjøgren.dk, arne@jøssen.dk") Currently only the last address is decoded, but the patch fixes a regexp in `article-decode-idna-rhs' so all are handled. 2. Also encode and decode address in Reply-To:, Mail-Reply-To: and Mail-Followup-To:. 3. When `message-use-idna is 'ask you will be asked whether to replace the same idna domain once for every time it is in a header (i.e. twice about jøssen.dk for "To: arne@jøssen.dk, palle@jøssen.dk") but the replacement is done the first time for both/all. The patch only asks once for the same idna domain in each header, but will still ask twice about jøssen.dk if it is present in both say To: and Reply-To: (that would require a bigger rewrite of the idna handling). Kind regards, -- Arne Jørgensen --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=idna.patch Content-Transfer-Encoding: 8bit Index: lisp/ChangeLog =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v retrieving revision 7.819 diff -u -p -r7.819 ChangeLog --- lisp/ChangeLog 27 Sep 2005 02:16:37 -0000 7.819 +++ lisp/ChangeLog 27 Sep 2005 14:25:06 -0000 @@ -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 Index: lisp/gnus-art.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-art.el,v retrieving revision 7.127 diff -u -p -r7.127 gnus-art.el --- lisp/gnus-art.el 27 Sep 2005 02:16:36 -0000 7.127 +++ lisp/gnus-art.el 27 Sep 2005 14:25:11 -0000 @@ -2385,20 +2385,22 @@ If PROMPT (the prefix), prompt for a cod (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))))))))) Index: lisp/message.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/message.el,v retrieving revision 7.95 diff -u -p -r7.95 message.el --- lisp/message.el 25 Sep 2005 21:27:48 -0000 7.95 +++ lisp/message.el 27 Sep 2005 14:25:16 -0000 @@ -2088,6 +2088,14 @@ With prefix-argument just set Follow-Up, ;;; 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 addition (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) --=-=-=--