Wrong punycode of IDN domains with cyrillic letters and hyphen [fixed]

Much of IDN domains added to system successfully, but at now I got one doman that added wrong (Virtualmin version 3.82.gpl):
Domain is

Correctly it must be converted to:

But virtualmin is convert it to:

And in list it show me domain name like:
instead of

Where is the source of the problem and how I can fix it?

This does look like a bug … maybe. From reading the IDN spec, it seems that all domain names that have been encoded to punycode should start with xn-- , so I am confused as to why this one starts with xn---- (four dashes) ?

This is because prefix is “xn–” and string converted to punycode is started with 2 dashes: --ba4b2kwackg3mbccbci
I try several punycode encoders and they add four dashes too:

So, looks like this is a bug in punycode converter in Virtualmin or Webmin…

Ok, that makes sense now. I found a bug in the Virtualmin code where it tries to fix incorrectly converted punycode domains that start with xn— (three dashes), but this was breaking domains starting with xn---- !

This will be fixed in the 3.85 release.

Confirm fixing in the 3.85 release.