Function: message-idna-to-ascii-rhs-1

message-idna-to-ascii-rhs-1 is a byte-compiled function defined in message.el.gz.

Signature

(message-idna-to-ascii-rhs-1 HEADER)

Documentation

Interactively potentially IDNA encode domain names in HEADER.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-idna-to-ascii-rhs-1 (header)
  "Interactively potentially IDNA encode domain names in HEADER."
  (let ((field (message-fetch-field header))
        ace)
    (when field
      (dolist (rhs
	       (delete-dups
		(mapcar (lambda (rhs) (or (cadr (split-string rhs "@")) ""))
			(mapcar #'downcase
				(mapcar
				 (lambda (elem)
				   (or (cadr elem)
				       ""))
				 (mail-extract-address-components field t))))))
	;; Note that `rhs' will be "" if the address does not have
	;; the domain part, i.e., if it is a local user's address.
	(setq ace (if (string-match "\\`[[:ascii:]]*\\'" rhs)
		      rhs
		    (downcase (puny-encode-domain rhs))))
	(when (and (not (equal rhs ace))
		   (or (not (eq message-use-idna 'ask))
		       (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)
	    (while (search-forward (concat "@" rhs) nil t)
	      (replace-match (concat "@" ace) t t))
	    (goto-char (point-max))
	    (widen)))))))