summaryrefslogtreecommitdiff
path: root/openid
diff options
context:
space:
mode:
authorVlastimil Zíma <vlastimil.zima@nic.cz>2018-03-09 14:24:21 +0100
committerVlastimil Zíma <vlastimil.zima@nic.cz>2018-04-30 14:20:16 +0200
commit276bd8b0625c9c316d7cdec6b3d231e7cd224da9 (patch)
tree4532e1958e55ec81d1346b30c734c9e40609a287 /openid
parenta1f864ada10d00edc1e58e5ecb97fab6ed319a62 (diff)
downloadopenid-276bd8b0625c9c316d7cdec6b3d231e7cd224da9.tar.gz
Clean trustroot module
* Remove useless code based on the changes in 'urinorm' function.
Diffstat (limited to 'openid')
-rw-r--r--openid/server/trustroot.py30
1 files changed, 4 insertions, 26 deletions
diff --git a/openid/server/trustroot.py b/openid/server/trustroot.py
index a71ed71..ed25895 100644
--- a/openid/server/trustroot.py
+++ b/openid/server/trustroot.py
@@ -19,7 +19,7 @@ __all__ = [
import logging
import re
-from urlparse import urlparse, urlunparse
+from urlparse import urlsplit, urlunsplit
from openid import urinorm
from openid.yadis import services
@@ -27,7 +27,6 @@ from openid.yadis import services
_LOGGER = logging.getLogger(__name__)
############################################
-_protocols = ['http', 'https']
_top_level_domains = [
'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an',
'ao', 'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw',
@@ -89,29 +88,12 @@ def _parseURL(url):
url = urinorm.urinorm(url)
except ValueError:
return None
- proto, netloc, path, params, query, frag = urlparse(url)
- if not path:
- path = '/'
- path = urlunparse(('', '', path, params, query, frag))
+ split_url = urlsplit(url)
- if ':' in netloc:
- try:
- host, port = netloc.split(':')
- except ValueError:
- return None
-
- if not re.match(r'\d+$', port):
- return None
- else:
- host = netloc
- port = ''
+ path = urlunsplit(('', '', split_url.path or '/', split_url.query, split_url.fragment))
- host = host.lower()
- if not host_segment_re.match(host):
- return None
-
- return proto, host, port, path
+ return split_url.scheme, split_url.hostname, split_url.port, path
class TrustRoot(object):
@@ -270,10 +252,6 @@ class TrustRoot(object):
proto, host, port, path = url_parts
- # check for valid prototype
- if proto not in _protocols:
- return None
-
# check for URI fragment
if path.find('#') != -1:
return None