Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits: 883361d4 by lovetox at 2022-08-29T18:10:13+02:00 cfix: Allow encoding domains to ascii - - - - - 1 changed file: - nbxmpp/protocol.py Changes: ===================================== nbxmpp/protocol.py ===================================== @@ -529,7 +529,7 @@ def validate_domainpart(domainpart: str) -> str: @functools.lru_cache(maxsize=None) -def idna2008_prep(domain: str) -> str: +def idna2008_prep(domain: str, to_ascii: bool = False) -> str: ''' Prepare with UTS46 case mapping to stay compatibel with the IDNA2003 mapping. Further try to encode the domain to catch illegal domains. @@ -537,7 +537,9 @@ def idna2008_prep(domain: str) -> str: are fine. ''' domain = idna.uts46_remap(domain) - idna.encode(domain) + encoded_domain = idna.encode(domain) + if to_ascii: + return encoded_domain.decode() return domain @@ -694,7 +696,7 @@ class JID: return not self.__eq__(other) def domain_to_ascii(self) -> str: - return idna_encode(self.domain) + return idna2008_prep(self.domain, to_ascii=True) @property def bare(self) -> str: View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/883361d4ffd173130cfd2848e3df434b86054289 -- View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/883361d4ffd173130cfd2848e3df434b86054289 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