Mastodon API: URI encode hashtag name in generated URLs
authorshadowfacts <me@shadowfacts.net>
Sat, 7 Sep 2019 19:50:45 +0000 (19:50 +0000)
committershadowfacts <me@shadowfacts.net>
Sat, 7 Sep 2019 19:50:45 +0000 (19:50 +0000)
Otherwise hashtags with word characters other than those allowed in URLs (e.g. Japanese characters) produce hashtag URLs that are invalid.

lib/pleroma/web/mastodon_api/views/status_view.ex

index e71083b918ffca8d2c21b5dcc81565f4605376e9..708b8c2fd2c5af2c0af6e944b4a89be6974ac9cb 100644 (file)
@@ -499,7 +499,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     object_tags = for tag when is_binary(tag) <- object_tags, do: tag
 
     Enum.reduce(object_tags, [], fn tag, tags ->
-      tags ++ [%{name: tag, url: "/tag/#{tag}"}]
+      tags ++ [%{name: tag, url: "/tag/#{URI.encode(tag)}"}]
     end)
   end