Skip to content
Snippets Groups Projects
Commit 09d5c94c authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

Follower and following entries must be strings. Same behaviour as in old hivemind

parent b5adae95
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!364Follower and following names validation and type check
...@@ -104,18 +104,15 @@ class Follow(DbAdapterHolder): ...@@ -104,18 +104,15 @@ class Follow(DbAdapterHolder):
op['following'] = op['following'] if isinstance(op['following'], list) else [op['following']] op['following'] = op['following'] if isinstance(op['following'], list) else [op['following']]
# additional layer of protection against putting complex data types as user names # additional layer of protection against putting complex data types as user names
as_str = [] # we expecting follower and following entries to be strings
# in older hivemind this check was done in Accounts.exists
# now following can be list of names so we need to check if all entries are strings
for following in op['following']: for following in op['following']:
if isinstance(following, list) or isinstance(following, dict): if not isinstance(following, str):
as_str.append(dumps(following)) return None
else:
as_str.append(str(following))
op['following'] = as_str
if isinstance(op['follower'], list) or isinstance(op['follower'], dict): if not isinstance(op['follower'], str):
op['follower'] = dumps(op['follower']) return None
else:
op['follower'] = str(op['follower'])
# follower/following is empty # follower/following is empty
if not op['follower'] or not op['following']: if not op['follower'] or not op['following']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment