escape attachment urls on creation.
authorRoger Braun <roger@rogerbraun.net>
Wed, 9 Aug 2017 14:55:18 +0000 (16:55 +0200)
committerRoger Braun <roger@rogerbraun.net>
Wed, 9 Aug 2017 14:55:18 +0000 (16:55 +0200)
lib/pleroma/web/twitter_api/utils.ex
test/web/twitter_api/twitter_api_utils_test.exs

index 2c3507dfbd6936158b29650c9edf25164fa81e3b..cd7e04ca1462b51066ff36f65e18fed13d5cfcc3 100644 (file)
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.TwitterAPI.Utils do
   def add_attachments(text, attachments) do
     attachment_text = Enum.map(attachments, fn
       (%{"url" => [%{"href" => href} | _]}) ->
-        "<a href=\"#{URI.encode(href)}\" class='attachment'>#{Path.basename(href)}</a>"
+        "<a href=\"#{href}\" class='attachment'>#{Path.basename(href)}</a>"
       _ -> ""
     end)
     Enum.join([text | attachment_text], "<br>\n")
index 62aa7843bc661fc07ed62776edcfb8b1a3003f20..49818afed7d80c6c934544240111260e3c861f13 100644 (file)
@@ -9,6 +9,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilsTest do
 
     res = Utils.add_attachments("", [attachment])
 
-    assert res == "<br>\n<a href=\"http://heise.de/i%22m%20a%20boy.png\" class='attachment'>i\"m a boy.png</a>"
+    assert res == "<br>\n<a href=\"http://heise.de/i\"m a boy.png\" class='attachment'>i\"m a boy.png</a>"
   end
 end