Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits: 1b7abc6d by lovetox at 2022-08-29T18:03:41+02:00 fix: Prepare domain names with UTS46 - - - - - 1 changed file: - nbxmpp/protocol.py Changes: ===================================== nbxmpp/protocol.py ===================================== @@ -521,7 +521,7 @@ def validate_domainpart(domainpart: str) -> str: domainpart = domainpart[:-1] try: - idna_encode(domainpart) + domainpart = idna2008_prep(domainpart) except Exception: raise DomainpartNotAllowedChar @@ -529,8 +529,16 @@ def validate_domainpart(domainpart: str) -> str: @functools.lru_cache(maxsize=None) -def idna_encode(domain: str) -> str: - return idna.encode(domain, uts46=True).decode() +def idna2008_prep(domain: str) -> str: + ''' + Prepare with UTS46 case mapping to stay compatibel with the IDNA2003 + mapping. Further try to encode the domain to catch illegal domains. + Only return the case mapped domain because on the XMPP wire,UTF8 domains + are fine. + ''' + domain = idna.uts46_remap(domain) + idna.encode(domain) + return domain @functools.lru_cache(maxsize=None) View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/1b7abc6de619bc331a2d57e621511dd3be27b982 -- View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/1b7abc6de619bc331a2d57e621511dd3be27b982 You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits