Add support for idn
This commit is contained in:
parent
d516c8ba48
commit
8ad184519b
|
@ -1,5 +1,11 @@
|
|||
# Jetforce Changelog
|
||||
|
||||
### v0.8.0 (Unreleased)
|
||||
|
||||
#### Spec Changes
|
||||
|
||||
- Added support for international domain names using IDN encoding.
|
||||
|
||||
### v0.7.0 (2020-12-06)
|
||||
|
||||
#### Spec Changes
|
||||
|
|
|
@ -102,6 +102,10 @@ receive traffic from. For example, if your jetforce server is running on
|
|||
that do not match this hostname will be refused by the server, including
|
||||
URLs that use a direct IP address such as "gemini://174.138.124.169".
|
||||
|
||||
IDNs (domain names that contain unicode characters) should be defined using
|
||||
their ASCII punycode representation. For example, the domain name
|
||||
*café.mozz.us* should be represented as ``--hostname xn--caf-dma.mozz.us``.
|
||||
|
||||
### Setting the ``host``
|
||||
|
||||
The server's host should be set to the local socket that you want to
|
||||
|
|
|
@ -62,7 +62,12 @@ class Request:
|
|||
if self.scheme == "gemini" and url_parts.username:
|
||||
raise ValueError("Invalid userinfo component")
|
||||
|
||||
self.hostname = url_parts.hostname
|
||||
# Convert domain names to punycode for compatibility with URLs that
|
||||
# contain encoded IDNs (follows RFC 3490).
|
||||
hostname = url_parts.hostname
|
||||
hostname = hostname.encode("idna").decode("ascii")
|
||||
|
||||
self.hostname = hostname
|
||||
self.port = url_parts.port
|
||||
|
||||
self.path = unquote(url_parts.path)
|
||||
|
|
Loading…
Reference in New Issue