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:
xn----otbnbhfh1i.xn–p1ai

But virtualmin is convert it to:
xn—otbnbhfh1i.xn–p1ai

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:
http://www.dnsqueries.com/en/punycode_encoder_decoder.php
http://www.motobit.com/util/punycode-decoder-encoder.asp
http://punycoder.com/

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.