Skip to content

Incorrect converting of πŸ‘ & πŸ‘οΈΒ #145

@james-stevens

Description

@james-stevens
$ 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'
>>>
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions