emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 023dc2a 3/3: Make puny-encode-string normalize first


From: Lars Ingebrigtsen
Subject: master 023dc2a 3/3: Make puny-encode-string normalize first
Date: Fri, 19 Nov 2021 01:46:14 -0500 (EST)

branch: master
commit 023dc2ac8fb004c16748fa98223a1fb88cfa2186
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 42a7e79..c1833ff 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 28c0d49..9119084 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]