diff --git a/xExtension-ImageProxy/README.md b/xExtension-ImageProxy/README.md index 748c590..f930f8d 100644 --- a/xExtension-ImageProxy/README.md +++ b/xExtension-ImageProxy/README.md @@ -12,7 +12,8 @@ To use it, upload this entire directory to the FreshRSS `./extensions` directory * `scheme_https` (default: `0`): whether to proxy HTTPS resources -* `scheme_default` (default: `http`): which scheme to use for resources that do not include one (if set to `-`, those will not be proxied) +* `scheme_default` (default: `auto`): which scheme to use for resources that do not include one; if set to `-`, those will not be proxied; + if set along `scheme_include`, the scheme included in the URL will either be `auto`-matically derived from your current connection or the one explicitly specified * `scheme_include` (default: `0`): whether to include the scheme - `http*://` - in the proxied URL diff --git a/xExtension-ImageProxy/configure.phtml b/xExtension-ImageProxy/configure.phtml index 2e054f0..fb66144 100644 --- a/xExtension-ImageProxy/configure.phtml +++ b/xExtension-ImageProxy/configure.phtml @@ -24,6 +24,7 @@ diff --git a/xExtension-ImageProxy/extension.php b/xExtension-ImageProxy/extension.php index 8d0e5fe..ce4c9af 100644 --- a/xExtension-ImageProxy/extension.php +++ b/xExtension-ImageProxy/extension.php @@ -5,7 +5,7 @@ class ImageProxyExtension extends Minz_Extension { private const PROXY_URL = 'https://images.weserv.nl/?url='; private const SCHEME_HTTP = '1'; private const SCHEME_HTTPS = ''; - private const SCHEME_DEFAULT = 'http'; + private const SCHEME_DEFAULT = 'auto'; private const SCHEME_INCLUDE = ''; private const URL_ENCODE = '1'; @@ -78,9 +78,18 @@ class ImageProxyExtension extends Minz_Extension { } } else if (empty($scheme)) { - if (substr(FreshRSS_Context::$user_conf->image_proxy_scheme_default,0, 4) !== 'http') return $url; - if (FreshRSS_Context::$user_conf->image_proxy_scheme_include) { - $url = FreshRSS_Context::$user_conf->image_proxy_scheme_default . '://' . $url; + if (FreshRSS_Context::$user_conf->image_proxy_scheme_default === 'auto') { + if (FreshRSS_Context::$user_conf->image_proxy_scheme_include) { + $url = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])!== 'off') ? 'https:' : 'http:') . $url; + } + } + else if (substr(FreshRSS_Context::$user_conf->image_proxy_scheme_default, 0, 4) === 'http') { + if (FreshRSS_Context::$user_conf->image_proxy_scheme_include) { + $url = FreshRSS_Context::$user_conf->image_proxy_scheme_default . ':' . $url; + } + } + else { // do not proxy unschemed ("//path/...") URLs + return $url; } } else { // unknown/unsupported (non-http) scheme