mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-06 22:23:10 -04:00
Better trim base_url (#4423)
Avoid usual errors for instance with quotes, especially when provided through Docker / CLI
This commit is contained in:
committed by
GitHub
parent
5b31c8212f
commit
47ab9d5e77
@@ -133,10 +133,8 @@ class Minz_Request {
|
||||
|
||||
/**
|
||||
* Return true if the request is over HTTPS, false otherwise (HTTP)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isHttps() {
|
||||
public static function isHttps(): bool {
|
||||
$header = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '';
|
||||
if ('' != $header) {
|
||||
return 'https' === strtolower($header);
|
||||
@@ -159,10 +157,7 @@ class Minz_Request {
|
||||
return filter_var("{$protocol}://{$host}{$port}{$prefix}{$path}", FILTER_SANITIZE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function extractProtocol() {
|
||||
private static function extractProtocol(): string {
|
||||
if (self::isHttps()) {
|
||||
return 'https';
|
||||
}
|
||||
@@ -202,10 +197,7 @@ class Minz_Request {
|
||||
return self::isHttps() ? 443 : 80;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function extractPortForUrl() {
|
||||
private static function extractPortForUrl(): string {
|
||||
if (self::isHttps() && 443 !== $port = self::extractPort()) {
|
||||
return ":{$port}";
|
||||
}
|
||||
@@ -215,10 +207,7 @@ class Minz_Request {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function extractPrefix() {
|
||||
private static function extractPrefix(): string {
|
||||
if ('' != $prefix = ($_SERVER['HTTP_X_FORWARDED_PREFIX'] ?? '')) {
|
||||
return rtrim($prefix, '/ ');
|
||||
}
|
||||
@@ -235,13 +224,11 @@ class Minz_Request {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base_url from configuration and add a suffix if given.
|
||||
*
|
||||
* @return string base_url with a suffix.
|
||||
* Return the base_url from configuration
|
||||
*/
|
||||
public static function getBaseUrl() {
|
||||
public static function getBaseUrl(): string {
|
||||
$conf = Minz_Configuration::get('system');
|
||||
$url = rtrim($conf->base_url, '/\\');
|
||||
$url = trim($conf->base_url, ' /\\"');
|
||||
return filter_var($url, FILTER_SANITIZE_URL);
|
||||
}
|
||||
|
||||
@@ -397,17 +384,11 @@ class Minz_Request {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function extractContentType() {
|
||||
private static function extractContentType(): string {
|
||||
return strtolower(trim($_SERVER['CONTENT_TYPE'] ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isPost() {
|
||||
public static function isPost(): bool {
|
||||
return 'POST' === ($_SERVER['REQUEST_METHOD'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user