From 023dc2ac8fb004c16748fa98223a1fb88cfa2186 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 19 Nov 2021 07:42:55 +0100 Subject: [PATCH] Make puny-encode-string normalize first * lisp/net/puny.el (puny-encode-string): Normalize before encoding (bug#51954). --- lisp/net/puny.el | 1 + test/lisp/net/puny-tests.el | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lisp/net/puny.el b/lisp/net/puny.el index 42a7e796798..c1833ffdb0b 100644 --- a/lisp/net/puny.el +++ b/lisp/net/puny.el @@ -43,6 +43,7 @@ For instance, \"fśf.org\" => \"xn--ff-2sa.org\"." "Encode STRING according to the IDNA/punycode algorithm. This is used to encode non-ASCII domain names. For instance, \"bücher\" => \"xn--bcher-kva\"." + (setq string (downcase (string-glyph-compose string))) (let ((ascii (seq-filter (lambda (char) (< char 128)) string))) diff --git a/test/lisp/net/puny-tests.el b/test/lisp/net/puny-tests.el index 28c0d49cbee..9119084209e 100644 --- a/test/lisp/net/puny-tests.el +++ b/test/lisp/net/puny-tests.el @@ -61,4 +61,11 @@ ;; Only allowed in unrestricted. (should-not (puny-highly-restrictive-domain-p "I♥NY.org"))) +(ert-deftest puny-normalize () + (should (equal (puny-encode-string (string-glyph-compose "Bä.com")) + "xn--b.com-gra")) + (should (equal (puny-encode-string "Bä.com") + "xn--b.com-gra")) + (should (equal (puny-encode-string "Bä.com") "xn--b.com-gra"))) + ;;; puny-tests.el ends here -- 2.39.5