diff options
author | Julian Berman <Julian@GrayVines.com> | 2019-01-04 09:17:01 +0000 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2019-01-04 09:17:01 +0000 |
commit | aa6cf9ea6ee54a92c19307f5d841a4c71fa702e9 (patch) | |
tree | 3fad0d46c77ca0bd72e25adf44c5d195d26db173 | |
parent | 17fb9cb006402f68b9fbf3b6877a778135f0aecc (diff) | |
download | jsonschema-aa6cf9ea6ee54a92c19307f5d841a4c71fa702e9.tar.gz |
idn-hostname validation.
-rw-r--r-- | jsonschema/_format.py | 14 | ||||
-rw-r--r-- | setup.cfg | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/jsonschema/_format.py b/jsonschema/_format.py index a06136c..e06f540 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -219,6 +219,20 @@ def is_host_name(instance): try: + # The built-in `idna` codec only implements RFC 3890, so we go elsewhere. + import idna +except ImportError: + pass +else: + @_checks_drafts(draft7="idn-hostname", raises=idna.IDNAError) + def is_idn_host_name(instance): + if not isinstance(instance, str_types): + return True + idna.encode(instance) + return True + + +try: import rfc3987 except ImportError: pass @@ -33,6 +33,7 @@ install_requires = [options.extras_require] format = + idna jsonpointer>1.13 rfc3987 strict-rfc3339 |