forked from AkkomaGang/akkoma
Compare commits
10 commits
b736086ab6
...
309d574ff9
Author | SHA1 | Date | |
---|---|---|---|
309d574ff9 | |||
e3c8c4f24f | |||
67cdc38296 | |||
89d209f486 | |||
087ada3b2e | |||
91bedcfa68 | |||
ff5d197341 | |||
7632765b43 | |||
416aebb76a | |||
4c7ef1e027 |
5 changed files with 15 additions and 4 deletions
|
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## UNRELEASED
|
||||
|
||||
## Fixed
|
||||
- Media proxy no longer attempts to proxy embedded images
|
||||
|
||||
## 3.13.3
|
||||
|
||||
## BREAKING
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
* PostgreSQL 12+
|
||||
* Elixir 1.14+ (currently tested up to 1.16)
|
||||
* Erlang OTP 25+ (currently tested up to OTP26)
|
||||
* Erlang OTP 25+ (currently tested up to OTP27)
|
||||
* git
|
||||
* file / libmagic
|
||||
* gcc (clang might also work)
|
||||
|
|
|
@ -52,11 +52,11 @@ def url(url) do
|
|||
|
||||
@spec url_proxiable?(String.t()) :: boolean()
|
||||
def url_proxiable?(url) do
|
||||
not local?(url) and not whitelisted?(url) and not blocked?(url)
|
||||
not local?(url) and not whitelisted?(url) and not blocked?(url) and http_scheme?(url)
|
||||
end
|
||||
|
||||
def preview_url(url, preview_params \\ []) do
|
||||
if preview_enabled?() do
|
||||
if preview_enabled?() and url_proxiable?(url) do
|
||||
encode_preview_url(url, preview_params)
|
||||
else
|
||||
url(url)
|
||||
|
@ -71,6 +71,8 @@ def preview_enabled?, do: enabled?() and !!Config.get([:media_preview_proxy, :en
|
|||
|
||||
def local?(url), do: String.starts_with?(url, Endpoint.url())
|
||||
|
||||
def http_scheme?(url), do: String.starts_with?(url, ["http:", "https:"])
|
||||
|
||||
def whitelisted?(url) do
|
||||
%{host: domain} = URI.parse(url)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def nodeinfo(conn, %{"version" => version}) when version in ["2.0", "2.1"] do
|
|||
conn
|
||||
|> put_resp_header(
|
||||
"content-type",
|
||||
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
|
||||
"application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/#{version}#\"; charset=utf-8"
|
||||
)
|
||||
|> json(Nodeinfo.get_nodeinfo(version))
|
||||
end
|
||||
|
|
|
@ -37,6 +37,10 @@ test "ignores local url" do
|
|||
assert MediaProxy.url(local_root) == local_root
|
||||
end
|
||||
|
||||
test "ignores data url" do
|
||||
assert MediaProxy.url("data:image/png;base64,") == "data:image/png;base64,"
|
||||
end
|
||||
|
||||
test "encodes and decodes URL" do
|
||||
url = "https://pleroma.soykaf.com/static/logo.png"
|
||||
encoded = MediaProxy.url(url)
|
||||
|
|
Loading…
Add table
Reference in a new issue