aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2016-04-17 19:29:58 +0200
committerLars Magne Ingebrigtsen2016-04-17 19:29:58 +0200
commit50b93f40d0d41ded6b9c0ee83574e828c869f62c (patch)
treeee3014346c8df661843e1caf207e60f8d6ff5bc3
parentc5dfaae30f1f7a9256e49d26ec5e69be608c8182 (diff)
downloademacs-50b93f40d0d41ded6b9c0ee83574e828c869f62c.tar.gz
emacs-50b93f40d0d41ded6b9c0ee83574e828c869f62c.zip
Use puny.el instead of idna.el functions in Gnus
* lisp/gnus/gnus-art.el (gnus-use-idna): Default to t (since Emacs comes with IDNA support built in). (article-decode-idna-rhs): Use `puny-decode-domain' instead of `idna-to-unicode'. * lisp/gnus/gnus-sum.el (gnus-summary-idna-message): Ditto.
-rw-r--r--lisp/gnus/gnus-art.el19
-rw-r--r--lisp/gnus/gnus-sum.el31
2 files changed, 14 insertions, 36 deletions
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 94ebbdd60c7..dea8d1f5c9f 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -1610,18 +1610,9 @@ It is a string, such as \"PGP\". If nil, ask user."
1610 :type 'string 1610 :type 'string
1611 :group 'mime-security) 1611 :group 'mime-security)
1612 1612
1613(defvar idna-program) 1613(defcustom gnus-use-idna t
1614 1614 "Whether IDNA decoding of headers is used when viewing messages."
1615(defcustom gnus-use-idna (and (mm-coding-system-p 'utf-8) 1615 :version "25.2"
1616 (condition-case nil
1617 (require 'idna)
1618 (file-error)
1619 (invalid-operation))
1620 idna-program
1621 (executable-find idna-program))
1622 "Whether IDNA decoding of headers is used when viewing messages.
1623This requires GNU Libidn, and by default only enabled if it is found."
1624 :version "22.1"
1625 :group 'gnus-article-headers 1616 :group 'gnus-article-headers
1626 :type 'boolean) 1617 :type 'boolean)
1627 1618
@@ -2591,8 +2582,6 @@ If PROMPT (the prefix), prompt for a coding system to use."
2591 t t nil 1)) 2582 t t nil 1))
2592 (goto-char (point-min))))))) 2583 (goto-char (point-min)))))))
2593 2584
2594(autoload 'idna-to-unicode "idna")
2595
2596(defun article-decode-idna-rhs () 2585(defun article-decode-idna-rhs ()
2597 "Decode IDNA strings in RHS in various headers in current buffer. 2586 "Decode IDNA strings in RHS in various headers in current buffer.
2598The following headers are decoded: From:, To:, Cc:, Reply-To:, 2587The following headers are decoded: From:, To:, Cc:, Reply-To:,
@@ -2610,7 +2599,7 @@ Mail-Reply-To: and Mail-Followup-To:."
2610 (save-excursion 2599 (save-excursion
2611 (and (re-search-backward "^[^ \t]" nil t) 2600 (and (re-search-backward "^[^ \t]" nil t)
2612 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To"))) 2601 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2613 (setq unicode (idna-to-unicode ace)))) 2602 (setq unicode (puny-decode-domain ace))))
2614 (unless (string= ace unicode) 2603 (unless (string= ace unicode)
2615 (replace-match unicode nil nil nil 1))))))))) 2604 (replace-match unicode nil nil nil 1)))))))))
2616 2605
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 6b3add2cddf..67b4268dbd9 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9807,8 +9807,6 @@ prefix specifies how many places to rotate each letter forward."
9807 ;; Create buttons and stuff... 9807 ;; Create buttons and stuff...
9808 (gnus-treat-article nil)) 9808 (gnus-treat-article nil))
9809 9809
9810(declare-function idna-to-unicode "ext:idna" (str))
9811
9812(defun gnus-summary-idna-message (&optional arg) 9810(defun gnus-summary-idna-message (&optional arg)
9813 "Decode IDNA encoded domain names in the current articles. 9811 "Decode IDNA encoded domain names in the current articles.
9814IDNA encoded domain names looks like `xn--bar'. If a string 9812IDNA encoded domain names looks like `xn--bar'. If a string
@@ -9818,25 +9816,16 @@ invalid IDNA string (`xn--bar' is invalid).
9818You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/') 9816You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9819installed for this command to work." 9817installed for this command to work."
9820 (interactive "P") 9818 (interactive "P")
9821 (if (not (and (mm-coding-system-p 'utf-8) 9819 (gnus-summary-select-article)
9822 (condition-case nil 9820 (let ((mail-header-separator ""))
9823 (require 'idna) 9821 (gnus-eval-in-buffer-window gnus-article-buffer
9824 (file-error) 9822 (save-restriction
9825 (invalid-operation)) 9823 (widen)
9826 (symbol-value 'idna-program) 9824 (let ((start (window-start))
9827 (executable-find (symbol-value 'idna-program)))) 9825 buffer-read-only)
9828 (gnus-message 9826 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9829 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)") 9827 (replace-match (puny-decode-domain (match-string 1))))
9830 (gnus-summary-select-article) 9828 (set-window-start (get-buffer-window (current-buffer)) start))))))
9831 (let ((mail-header-separator ""))
9832 (gnus-eval-in-buffer-window gnus-article-buffer
9833 (save-restriction
9834 (widen)
9835 (let ((start (window-start))
9836 buffer-read-only)
9837 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9838 (replace-match (idna-to-unicode (match-string 1))))
9839 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9840 9829
9841(defun gnus-summary-morse-message (&optional arg) 9830(defun gnus-summary-morse-message (&optional arg)
9842 "Morse decode the current article." 9831 "Morse decode the current article."