Function: article-decode-idna-rhs

article-decode-idna-rhs is a byte-compiled function defined in gnus-art.el.gz.

Signature

(article-decode-idna-rhs)

Documentation

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:.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun article-decode-idna-rhs ()
  "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-read-only t))
	(article-narrow-to-head)
	(goto-char (point-min))
	(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\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
			 (setq unicode (puny-decode-domain ace))))
	      (unless (string= ace unicode)
		(replace-match unicode nil nil nil 1)))))))))