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

Implement is_idna #158

Closed
wants to merge 7 commits into from
Closed

Conversation

elliotwutingfeng
Copy link
Contributor

Closes #149.

Assumption: Does idna.encode() always throw an exception for strings that contain invalid punycode and/or unconvertible unicode (such as emojis)?


is_idna(s) returns True if a given string s can be encoded by idna.encode() without error, and at least one of its encoded labels begins with b"xn--".

A more efficient implementation would be to reuse portions of idna.encode() so that the per-label b"xn--" checks can be done before doing s = b'.'.join(result) for the final valid_string_length() check.

@elliotwutingfeng elliotwutingfeng marked this pull request as ready for review November 24, 2023 15:22
@kjd
Copy link
Owner

kjd commented Dec 4, 2023

I'm reluctant to merge this PR. Only one person has asked for this functionality and hasn't even confirmed in their issue that this is even what they are looking for. Given it is only subtly different from using encode() for the same purpose I am not sure it is worth adding this new function.

@elliotwutingfeng
Copy link
Contributor Author

Alright, I think this should be closed for now and left for future reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function to check if a string is an idna domain
2 participants