]> git.eshelyaron.com Git - emacs.git/commitdiff
Make puny-encode-string normalize first
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 19 Nov 2021 06:42:55 +0000 (07:42 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 19 Nov 2021 06:46:06 +0000 (07:46 +0100)
* lisp/net/puny.el (puny-encode-string): Normalize before encoding
(bug#51954).

lisp/net/puny.el
test/lisp/net/puny-tests.el

index 42a7e7967985835d987deb6e2f542de00f67a9e9..c1833ffdb0bbb0d79e67fa59b66b93aeece26ad4 100644 (file)
@@ -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)))
index 28c0d49cbeef14376dc34b1354ce2d1f0b427466..9119084209ea2e360fa42f7152aaa42625f87b07 100644 (file)
   ;; 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