Skip to content

Commit

Permalink
Decode url-encoded slug before comparing (#157)
Browse files Browse the repository at this point in the history
Tumblr allows for slugs that contain non url safe characters
meaning that they will get URL encoded. However, when we compare
the given slug against the post's actual slug a correct slug will
return a false equality check due to it being URL encoded.

Thus we need to decode the url before comparing
  • Loading branch information
syeopite authored Dec 22, 2024
1 parent 3188542 commit b4a982b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/blogs/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ async def before_blog_post_request(request):

# Check if slug is passed
if slug := request.match_info.get("slug"):
slug = urllib.parse.unquote(slug)

# Redirect to the correct slug if the given slug does not match the post's slug
if slug != post.slug:
# Unless of course the post doesn't have a slug in the first place in which
Expand Down

0 comments on commit b4a982b

Please sign in to comment.