[Top][All Lists]

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

bug#23688: 25.1.50; Incorrect punycode decoding for names without ASCII

From: Glenn Morris
Subject: bug#23688: 25.1.50; Incorrect punycode decoding for names without ASCII characters
Date: Wed, 01 Mar 2017 20:39:17 -0500
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Version: 26.1

Magnus Henoch wrote:

> When decoding an IDN label that doesn't contain any ASCII characters,
> the function puny-decode-string-internal would skip the first letter,
> thereby returning gibberish instead of the expected result.
> That is, the example in the puny-decode-string docstring,
> "xn--bcher-kva", would be decoded correctly since it finds the "kva"
> part after the last dash, but my domain "xn--9dbdkw.se" would not,
> since there is no "last dash".
> This patch seems to fix the problem:

Thanks. That patch did not seem quite right (eg try it on "xn--bcher-kva"),
so I applied the following, which works for me.

commit 8c1e16b
Date:   Wed Mar 1 20:35:41 2017 -0500

    Small puny.el fix
    * lisp/net/puny.el (puny-decode-string-internal):
    Handle strings with no ascii parts.  (Bug#23688)

diff --git a/lisp/net/puny.el b/lisp/net/puny.el
index c718d95..bdd59be 100644
--- a/lisp/net/puny.el
+++ b/lisp/net/puny.el
@@ -150,10 +150,12 @@ For instance \"xn--bcher-kva\" => \"b├╝cher\"."
 (defun puny-decode-string-internal (string)
     (insert string)
-    (goto-char (point-max))
-    (search-backward "-" nil (point-min))
-    ;; The encoded chars are after the final dash.
-    (let ((encoded (buffer-substring (1+ (point)) (point-max)))
+    ;; The encoded chars are after any final dash, else the whole string.
+    (let ((encoded (buffer-substring
+                    (if (search-backward "-" nil 'move)
+                        (1+ (point))
+                      (point))
+                    (point-max)))
           (ic 0)
           (i 0)
           (bias puny-initial-bias)

reply via email to

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