fix: [tags] invalid tags

This commit is contained in:
Terrtia 2021-04-26 15:08:36 +02:00
parent 0dd4854916
commit f94159b684
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -50,12 +50,18 @@ def is_tags_safe(ltags):
#### Taxonomies - Galaxies #### #### Taxonomies - Galaxies ####
def get_taxonomie_from_tag(tag): def get_taxonomie_from_tag(tag):
return tag.split(':')[0] try:
return tag.split(':')[0]
except IndexError:
return None
def get_galaxy_from_tag(tag): def get_galaxy_from_tag(tag):
galaxy = tag.split(':')[1] try:
galaxy = galaxy.split('=')[0] galaxy = tag.split(':')[1]
return galaxy galaxy = galaxy.split('=')[0]
return galaxy
except IndexError:
return None
def get_active_taxonomies(): def get_active_taxonomies():
return r_serv_tags.smembers('active_taxonomies') return r_serv_tags.smembers('active_taxonomies')
@ -110,6 +116,8 @@ def is_valid_tags_taxonomies_galaxy(list_tags, list_tags_galaxy):
for tag in list_tags: for tag in list_tags:
taxonomie = get_taxonomie_from_tag(tag) taxonomie = get_taxonomie_from_tag(tag)
if taxonomie is None:
return False
if taxonomie not in active_taxonomies: if taxonomie not in active_taxonomies:
return False return False
if not is_taxonomie_tag_enabled(taxonomie, tag): if not is_taxonomie_tag_enabled(taxonomie, tag):
@ -120,6 +128,8 @@ def is_valid_tags_taxonomies_galaxy(list_tags, list_tags_galaxy):
for tag in list_tags_galaxy: for tag in list_tags_galaxy:
galaxy = get_galaxy_from_tag(tag) galaxy = get_galaxy_from_tag(tag)
if galaxy is None:
return False
if galaxy not in active_galaxies: if galaxy not in active_galaxies:
return False return False
if not is_galaxy_tag_enabled(galaxy, tag): if not is_galaxy_tag_enabled(galaxy, tag):