Don't proxy s.pximg.net

Example user: 19467540
This commit is contained in:
blankie 2023-04-09 15:17:06 +07:00
parent 86749d3fbf
commit fef9a2f36e
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 5 additions and 1 deletions

View File

@ -8,7 +8,7 @@ void serve(const httplib::Request& req, httplib::Response& res, const Config& co
std::string css_url = get_origin(req, config) + "/style.css";
res.set_header("Content-Security-Policy", "default-src 'none'; style-src "s + css_url
+ "; img-src " + config.image_proxy_url.get_origin());
+ "; img-src https://s.pximg.net " + config.image_proxy_url.get_origin());
Element html("html", {
Element("head", {
@ -73,6 +73,10 @@ std::string get_origin(const httplib::Request& req, const Config& config) {
}
std::string proxy_image_url(const Config& config, blankie::murl::Url url) {
if (url.hostname == "s.pximg.net") {
return url.to_string();
}
blankie::murl::Url new_url = config.image_proxy_url;
if (!url.path.empty() && url.path[0] != '/') {
new_url.path += '/';