Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for idna tr domains #245

Merged
merged 7 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -173,7 +173,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