diff options
author | willson-chen <willson.chenwx@gmail.com> | 2020-08-07 11:04:31 +0800 |
---|---|---|
committer | willson-chen <willson.chenwx@gmail.com> | 2020-08-07 12:07:47 +0800 |
commit | 3b5f927e981576567018146a574e82bcc3a1947a (patch) | |
tree | c1e48cf1ab7b461f49ad406f3ca9d611925cbc00 /jsonschema/_format.py | |
parent | 506cea3e52699bedeab62971d3bdf23936b901d0 (diff) | |
download | jsonschema-3b5f927e981576567018146a574e82bcc3a1947a.tar.gz |
fix bug about hostname by import fqdn
Diffstat (limited to 'jsonschema/_format.py')
-rw-r--r-- | jsonschema/_format.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/jsonschema/_format.py b/jsonschema/_format.py index 3c1e6fe..691055e 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -4,6 +4,7 @@ import socket import struct from jsonschema.exceptions import FormatError +from fqdn import FQDN class FormatChecker(object): @@ -209,9 +210,6 @@ if hasattr(socket, "inet_pton"): return socket.inet_pton(socket.AF_INET6, instance) -_host_name_re = re.compile(r"^[A-Za-z0-9][A-Za-z0-9\.\-]{1,255}$") - - @_checks_drafts( draft3="host-name", draft4="hostname", @@ -221,13 +219,7 @@ _host_name_re = re.compile(r"^[A-Za-z0-9][A-Za-z0-9\.\-]{1,255}$") def is_host_name(instance): if not isinstance(instance, str): return True - if not _host_name_re.match(instance): - return False - components = instance.split(".") - for component in components: - if len(component) > 63: - return False - return True + return FQDN(instance).is_valid try: |