mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
89c1c1c5a8
commit
10238f0a09
34
context.py
34
context.py
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Security"
|
__module_group__ = "Security"
|
||||||
|
|
||||||
|
|
||||||
validContexts = (
|
VALID_CONTEXTS = (
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
"https://w3id.org/identity/v1",
|
"https://w3id.org/identity/v1",
|
||||||
"https://w3id.org/security/v1",
|
"https://w3id.org/security/v1",
|
||||||
|
@ -47,28 +47,28 @@ def has_valid_context(post_json_object: {}) -> bool:
|
||||||
for url in post_json_object['@context']:
|
for url in post_json_object['@context']:
|
||||||
if not isinstance(url, str):
|
if not isinstance(url, str):
|
||||||
continue
|
continue
|
||||||
if url not in validContexts:
|
if url not in VALID_CONTEXTS:
|
||||||
wildcardFound = False
|
wildcard_found = False
|
||||||
for c in validContexts:
|
for cont in VALID_CONTEXTS:
|
||||||
if c.startswith('*'):
|
if cont.startswith('*'):
|
||||||
c = c.replace('*', '')
|
cont = cont.replace('*', '')
|
||||||
if url.endswith(c):
|
if url.endswith(cont):
|
||||||
wildcardFound = True
|
wildcard_found = True
|
||||||
break
|
break
|
||||||
if not wildcardFound:
|
if not wildcard_found:
|
||||||
print('Unrecognized @context: ' + url)
|
print('Unrecognized @context: ' + url)
|
||||||
return False
|
return False
|
||||||
elif isinstance(post_json_object['@context'], str):
|
elif isinstance(post_json_object['@context'], str):
|
||||||
url = post_json_object['@context']
|
url = post_json_object['@context']
|
||||||
if url not in validContexts:
|
if url not in VALID_CONTEXTS:
|
||||||
wildcardFound = False
|
wildcard_found = False
|
||||||
for c in validContexts:
|
for cont in VALID_CONTEXTS:
|
||||||
if c.startswith('*'):
|
if cont.startswith('*'):
|
||||||
c = c.replace('*', '')
|
cont = cont.replace('*', '')
|
||||||
if url.endswith(c):
|
if url.endswith(cont):
|
||||||
wildcardFound = True
|
wildcard_found = True
|
||||||
break
|
break
|
||||||
if not wildcardFound:
|
if not wildcard_found:
|
||||||
print('Unrecognized @context: ' + url)
|
print('Unrecognized @context: ' + url)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue