do not break previous behavior for unschemed URLs
This commit is contained in:
parent
06b7fdef67
commit
cc24497c5c
3 changed files with 16 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
<select name="image_proxy_scheme_default" id="image_proxy_scheme_default">
|
||||
<option value="<?php echo htmlentities(FreshRSS_Context::$user_conf->image_proxy_scheme_default); ?>" selected="selected"><?php echo htmlentities(FreshRSS_Context::$user_conf->image_proxy_scheme_default); ?></option>
|
||||
<option value="-">-</option>
|
||||
<option value="auto">auto</option>
|
||||
<option value="http">http</option>
|
||||
<option value="https">https</option>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue