Skip to content

Commit

Permalink
Converting tags to lower-case in REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
devos50 authored and drew2a committed Oct 8, 2021
1 parent 4a7dcf0 commit 5f95718
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def add_tags_to_metadata_list(self, contents_list, hide_xxx=False):
if torrent['type'] == REGULAR_TORRENT:
tags = self.tags_db.get_tags(unhexlify(torrent["infohash"]))
if hide_xxx:
tags = [tag for tag in tags if not default_xxx_filter.isXXX(tag, isFilename=False)]
tags = [tag.lower() for tag in tags if not default_xxx_filter.isXXX(tag, isFilename=False)]
torrent["tags"] = tags

def get_channel_from_request(self, request):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ async def update_tags_entries(self, request):
except binascii.Error:
return RESTResponse({"error": "Invalid infohash"}, status=HTTP_BAD_REQUEST)

tags = set([tag.lower() for tag in params["tags"]])

# Validate whether the size of the tag is within the allowed range
for tag in set(params["tags"]):
for tag in tags:
if len(tag) < MIN_TAG_LENGTH or len(tag) > MAX_TAG_LENGTH:
return RESTResponse({"error": "Invalid tag length"}, status=HTTP_BAD_REQUEST)

self.modify_tags(infohash, set(params["tags"]))
self.modify_tags(infohash, tags)

return RESTResponse({"success": True})

Expand Down

0 comments on commit 5f95718

Please sign in to comment.