Skip to content

Conversation

@mimi89999
Copy link

Summary

Emoji domains (e.g., https://xn--i-7iq.ws/, https://xn--ls8h.la/) are not allowed by IDNA2008 but are supported by some TLDs, have valid TLS certificates, and work in browsers, curl, and Python's requests library.

Previously, httpx would raise an IDNAError when attempting to decode these Punycode domains, preventing legitimate requests.

This PR modifies the host property to gracefully handle IDNA decode errors by catching idna.IDNAError and keeping the original xn-- encoded form. This allows httpx to work with these real-world emoji domains.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@mimi89999
Copy link
Author

mimi89999 commented Nov 14, 2025

Alternatively, httpx/_models.py could be changed to check self.url.raw_host instead of checking self.url.host. I'm not sure which approach would be preferred. I prefer the approach that I proposed because it matches browser behavior of displaying the raw Punycode on decode errors rather than failing.

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.

1 participant