Skip to content

Add check for a valid domain on HTTP request

Fixes #672 (closed)

Adds a check that a requested domain is indeed valid before calling Tesla

When throwing an invalid domain, HTTP requests do not timeout despite all relevent parameters being set.

Reproducable via

iex> activity = Pleroma.Activity.get_by_id("9g8YrtJqfxFqY3sq1o")
iex> object = Pleroma.Object.normalize(activity.data["object"])
iex> data = object.data |> Map.put("content", "<a href=\"http://some_server/v1/\">http://some_server/v1/</a>")
iex> object = Map.put(object, :data, data)
iex> {:ok, url} = Pleroma.HTML.extract_first_external_url(object, object.data["content"])
iex> {:ok, rich_media} = Pleroma.Web.RichMedia.Parser.parse(url)

Adding debug logging shows that the hang is on

{:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url, [], adapter: @hackney_options)

Whether this is due to a bug in underlying libraries or not is kinda beyond my knowledge - the arguments appear to match what Tesla wants to set a timeout, however that timeout is never thrown.

Edited by Sadposter

Merge request reports