public-awesome / names

Stargaze Names: A Cosmos IBC Name Service and Marketplace
Apache License 2.0
21 stars 6 forks source link

Name validity verification check forbids punycode #234

Open angrymouse opened 1 year ago

angrymouse commented 1 year ago

Names minter contract forbids "--" at 2-4 position of name due to DNS spec. https://github.com/public-awesome/names/blob/main/contracts/name-minter/src/contract.rs#L307 This restriction is in there by reason - this space is reserved for identifying that name is punycode encoded (basically that it contains unicode like emojis). By just forbidding to put -- there, we also forbid using punycode (aka use emojis in names, etc). We need to forbid only if it doesn't start from "xn--", so if it is not punycode. So we basically need to add one more condition to if statement: !name[0..4].contains("xn--"). It will allow emoji names/domains, however not breaking DNS spec as punycode is fully supported there.

yubrew commented 1 year ago

pseudocode from discord

if len > 4 && name[2..4].contains("--") && !name[0..4].contains("xn--"){
  return Err(ContractError::InvalidName {});
}