mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 07:12:36 +00:00
a75d5b8bc1
To prevent them being considered for redirects. Includes test to cover. For #4863
35 lines
897 B
PHP
35 lines
897 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Session\Middleware\StartSession as Middleware;
|
|
|
|
/**
|
|
* An extended version of the default Laravel "StartSession" middleware
|
|
* with customizations applied as required:
|
|
*
|
|
* - Adds filtering for the request URLs stored in session history.
|
|
*/
|
|
class StartSessionExtended extends Middleware
|
|
{
|
|
protected static array $pathPrefixesExcludedFromHistory = [
|
|
'uploads/images/'
|
|
];
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
protected function storeCurrentUrl(Request $request, $session): void
|
|
{
|
|
$requestPath = strtolower($request->path());
|
|
foreach (static::$pathPrefixesExcludedFromHistory as $excludedPath) {
|
|
if (str_starts_with($requestPath, $excludedPath)) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
parent::storeCurrentUrl($request, $session);
|
|
}
|
|
}
|