Skip to content

Commit

Permalink
Merge pull request #245 from ofaruk89/fix_for_idna_tr_domains
Browse files Browse the repository at this point in the history
Fix for idna tr domains
  • Loading branch information
richardpenman authored Nov 17, 2024
2 parents 70463c2 + efe3ec3 commit a493897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions whois/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=False):
def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=False, convert_punycode=True):
# clean domain to expose netloc
ip_match = IPV4_OR_V6.match(url)
if ip_match:
Expand All @@ -43,7 +43,10 @@ def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=
else:
# try builtin client
nic_client = NICClient()
text = nic_client.whois_lookup(None, domain.encode("idna"), flags, quiet=quiet)
if convert_punycode:
text = nic_client.whois_lookup(None, domain.encode("idna"), flags, quiet=quiet)
else:
text = nic_client.whois_lookup(None, domain, flags, quiet=quiet)
entry = WhoisEntry.load(domain, text)
if inc_raw:
entry["raw"] = text
Expand Down
2 changes: 1 addition & 1 deletion whois/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __str__(self):
def handler(e):
return str(e)

return json.dumps(self, indent=2, default=handler)
return json.dumps(self, indent=2, default=handler, ensure_ascii=False)

def __getstate__(self):
return self.__dict__
Expand Down

0 comments on commit a493897

Please sign in to comment.