Commit 883361d4 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

cfix: Allow encoding domains to ascii

parent 1b7abc6d
Pipeline #10826 passed with stages
in 47 seconds
......@@ -529,7 +529,7 @@ def validate_domainpart(domainpart: str) -> str:
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)
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)
def bare(self) -> str:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment