From 79f102c25d8125f7ff145269627d8146d66b951c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 15 Sep 2020 08:02:28 +0300 Subject: af_proxy_http: never print received data directly, always redirect to cached_url cache/getUrl: basename() passed filename just in case --- classes/diskcache.php | 2 +- plugins/af_proxy_http/init.php | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/classes/diskcache.php b/classes/diskcache.php index 74415189c..da7722bf0 100644 --- a/classes/diskcache.php +++ b/classes/diskcache.php @@ -273,7 +273,7 @@ class DiskCache { } public function getUrl($filename) { - return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename; + return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . basename($filename); } // check for locally cached (media) URLs and rewrite to local versions diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 936942387..1d518c9c2 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -62,17 +62,10 @@ class Af_Proxy_Http extends Plugin { $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); if ($data) { - - $disable_cache = $this->host->get($this, "disable_cache"); - - if (!$disable_cache) { - if ($this->cache->put($local_filename, $data)) { - header("Location: " . $this->cache->getUrl($local_filename)); - return; - } + if ($this->cache->put($local_filename, $data)) { + header("Location: " . $this->cache->getUrl($local_filename)); + return; } - - print $data; } else { global $fetch_last_error; global $fetch_last_error_code; @@ -232,10 +225,6 @@ class Af_Proxy_Http extends Plugin { print_checkbox("proxy_all", $proxy_all); print " 
"; - $disable_cache = $this->host->get($this, "disable_cache"); - print_checkbox("disable_cache", $disable_cache); - print " "; - print "

"; print_button("submit", __("Save")); print ""; @@ -245,10 +234,8 @@ class Af_Proxy_Http extends Plugin { function save() { $proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]); - $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]); $this->host->set($this, "proxy_all", $proxy_all, false); - $this->host->set($this, "disable_cache", $disable_cache); echo __("Configuration saved"); } -- cgit v1.2.3