-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
$ cat puny.js
#! /usr/bin/node
const punycode = require('punycode/');
console.log(punycode.toUnicode("xn--mp8h"));
console.log(punycode.toUnicode("xn--v86cr064b"));
console.log(punycode.toASCII("π"));
console.log(punycode.toASCII("ποΈ"));
$ ./puny.js
π
ποΈ
xn--mp8h
xn--v86cr064b
The punycode xn--v86cr064b is invalid, so should throw an error or something, and both code points should map to xn--mp8h - this is the result you will get from Python's integrated .idn() encoding and the result you get from https://www.punycoder.com/
$ python3
Python 3.12.12 (main, Oct 11 2025, 15:09:54) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> utf8="π"
>>> print(utf8.encode("idna"))
b'xn--mp8h'
>>> utf8="ποΈ"
>>> print(utf8.encode("idna"))
b'xn--mp8h'
>>>
You could def make the case your code was never intended to be IDNA compliant, but only a punycode converter - however, if it is outputting domain names that are effectively "illegal", this seems to me highly undesirable behaviour - or at least, something users need an obvious and strongly worded warning about.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels