mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-07-28 15:57:27 -04:00
Redirect away from wrong URL paths to fix displaying of relative URLs (#9075)
* Redirect away from wrong URL paths to fix displaying of relative URLs * Also strip path info for API pages * Error for API --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
This commit is contained in:
@@ -39,12 +39,15 @@ class Minz_FrontController {
|
||||
|
||||
Minz_Request::init();
|
||||
|
||||
// Build the current request's URL and forward to it directly.
|
||||
// If needed, a redirect is issued instead to correct the public relative path.
|
||||
$url = Minz_Url::build();
|
||||
$url['params'] = array_merge(
|
||||
empty($url['params']) || !is_array($url['params']) ? [] : $url['params'],
|
||||
array_filter($_POST, 'is_string', ARRAY_FILTER_USE_KEY)
|
||||
);
|
||||
Minz_Request::forward($url);
|
||||
$pathInfo = $_SERVER['PATH_INFO'] ?? $_SERVER['ORIG_PATH_INFO'] ?? '';
|
||||
Minz_Request::forward($url, redirect: $pathInfo !== '');
|
||||
} catch (Minz_Exception $e) {
|
||||
Minz_Log::error($e->getMessage());
|
||||
self::killApp($e->getMessage());
|
||||
|
||||
@@ -12,6 +12,12 @@ $frameAncestors = FreshRSS_Context::systemConf()->attributeString('csp.frame-anc
|
||||
header("Content-Security-Policy: default-src 'self'; frame-ancestors $frameAncestors");
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
if (($_SERVER['PATH_INFO'] ?? $_SERVER['ORIG_PATH_INFO'] ?? '') !== '') {
|
||||
// Do not allow trailing slashes
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
die('Invalid path!');
|
||||
}
|
||||
|
||||
Minz_Translate::init(Minz_Translate::getLanguage(null, Minz_Request::getPreferredLanguages(), null));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
@@ -38,6 +38,12 @@ if (!FreshRSS_Context::hasSystemConf() || !FreshRSS_Context::systemConf()->api_e
|
||||
die('Service Unavailable!');
|
||||
}
|
||||
|
||||
if (($_SERVER['PATH_INFO'] ?? $_SERVER['ORIG_PATH_INFO'] ?? '') !== '') {
|
||||
// Do not allow trailing slashes
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
die('Invalid path!');
|
||||
}
|
||||
|
||||
FreshRSS_Context::initUser($user);
|
||||
if (!FreshRSS_Context::hasUserConf() || !FreshRSS_Context::userConf()->enabled) {
|
||||
usleep(rand(100, 10000)); //Primitive mitigation of scanning for users
|
||||
|
||||
Reference in New Issue
Block a user