Comments (6)
furl v0.5.1 is hot of the presses and supports Unicode hosts via Python's IDNA
support.
>>> import furl
>>> furl.__version__
'0.5'
>>> f = furl.furl('http://xn--4cab6c.se/')
>>> f.host
'åäö.se'
>>> f.set(host=u'ドメイン.テスト').url
'http://xn--eckwd4c7c.xn--zckzah/'
Update with
pip install --upgrade furl
I deferred IDNA2008 support. We'll cross that bridge when it becomes an issue.
Thank you for bringing this issue to my attention Jacob. Don't hesitate to let
me know if there's anything else I can do for you.
from furl.
Wonderful suggestion. furl should absolutely support non-ASCII hosts via IDNA
encoding.
I'll add this shortly. Or, pull requests welcome.
That said, IDNA support is a tad delicate.
-
Python's native idna implementation isn't up to spec: it supports IDNA2003
but not the latest IDNA2008. See http://bugs.python.org/issue17305. -
The idna library (https://pypi.python.org/pypi/idna) supports the latest
IDNA2008, but furl should require as few dependencies as possible. At best,
the idna library becomes an optional dependency. -
As I've encountered independently, the idna library's
idna.encode()
barfs
on perfectly valid URLs if the URL resembles an IDNA encoded URL. For
example,idna.encode()
barfs on the perfectly valid URLu'xx--åäö.se'
:>>> import idna >>> idna.encode(u'xx--åäö.se') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/idna/core.py", line 355, in encode result.append(alabel(label)) File "/usr/local/lib/python2.7/dist-packages/idna/core.py", line 276, in alabel check_label(label) File "/usr/local/lib/python2.7/dist-packages/idna/core.py", line 239, in check_label check_hyphen_ok(label) File "/usr/local/lib/python2.7/dist-packages/idna/core.py", line 134, in check_hyphen_ok raise IDNAError('Label has disallowed hyphens in 3rd and 4th position') idna.core.IDNAError: Label has disallowed hyphens in 3rd and 4th position
If furl uses the idna library, it needs to account for this behavior.
from furl.
Interesting, didn't know about # 3. Perhaps this is something that should be fixed in the idna
library in itself though?
from furl.
Excellent, seems to be working well for my use cases at least 😀
from furl.
Wunderbar.
Let me know if you encounter any problems or have any other comments,
suggestions, or recommendations. Feedback is how good products become great.
from furl.
Will do! Thanks for the implementation!
from furl.
Related Issues (20)
- furl doesn't type-hint itself as Text HOT 3
- url parsing still accepts semicolon as separator HOT 5
- Add typing support HOT 6
- Hi, if the URL is like '127.0.0.1:8080/a/b', the result is '8080/a/b', which seems incorrect HOT 2
- How handle javascript:void(0) HOT 2
- Feature: Addition of `is_domain` flag
- Maximum recursion depth exceeded error for url with large list HOT 3
- Adding README to PyPi HOT 2
- '127.0.0.1:8329' parsed wrong in Python 3.9+ HOT 3
- Add SECURITY.md HOT 3
- Feature request: Convert to unescaped string HOT 2
- .join() and .path.normalize() incorrectly interpret base paths ending /. or /..
- furl.path object is NOT of type: pathlib.Path HOT 1
- Feature requests: get url relative to another url
- Setting multiple query params for the same key and resultant url format
- Seems to be a bug when paring multiple '@'s ?
- Use the `ipaddress` module to detect valid IPV6 HOT 1
- a method to set an individual query parameter without removing the rest or keeping the original value
- Removes "git@" from git remote URL HOT 1
- URL fragment percent-encoding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from furl.