aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorrr-2016-05-10 12:17:42 +0200
committerrr-2016-05-10 12:18:06 +0200
commit03498b2d8e775c6688285571e1407ca6ad332f78 (patch)
tree5cfdc411cf61381be2130d53cf9e66b64a3a87f9 /server
parent14a20e55f8c44ac78c3e59493a4540c4d6d95163 (diff)
server/tags: add tag category color sanitization
Diffstat (limited to 'server')
-rw-r--r--server/szurubooru/func/tag_categories.py2
-rw-r--r--server/szurubooru/tests/api/test_tag_category_updating.py1
2 files changed, 3 insertions, 0 deletions
diff --git a/server/szurubooru/func/tag_categories.py b/server/szurubooru/func/tag_categories.py
index beeef9b..c5f088f 100644
--- a/server/szurubooru/func/tag_categories.py
+++ b/server/szurubooru/func/tag_categories.py
@@ -51,6 +51,8 @@ def update_category_name(category, name):
def update_category_color(category, color):
if not color:
raise InvalidTagCategoryNameError('Color cannot be empty.')
+ if not re.match(r'^#?[a-z]+$', color):
+ raise InvalidTagCategoryNameError('Invalid color.')
if util.value_exceeds_column_size(color, db.TagCategory.color):
raise InvalidTagCategoryColorError('Color is too long.')
category.color = color
diff --git a/server/szurubooru/tests/api/test_tag_category_updating.py b/server/szurubooru/tests/api/test_tag_category_updating.py
index fad6268..15a100a 100644
--- a/server/szurubooru/tests/api/test_tag_category_updating.py
+++ b/server/szurubooru/tests/api/test_tag_category_updating.py
@@ -56,6 +56,7 @@ def test_simple_updating(test_ctx):
{'name': '!bad'},
{'color': None},
{'color': ''},
+ {'color': '; float:left'},
])
def test_trying_to_pass_invalid_input(test_ctx, input):
db.session.add(test_ctx.tag_category_factory(name='meta', color='black'))

© 2015 - 2026 Jakob L. Kreuze