proofdb/vendor/illuminate/http/Middleware/ValidatePathEncoding.php
2026-05-01 23:40:14 +08:00

31 lines
756 B
PHP

<?php
namespace Illuminate\Http\Middleware;
use Closure;
use Illuminate\Http\Exceptions\MalformedUrlException;
use Illuminate\Http\Request;
class ValidatePathEncoding
{
/**
* Validate that the incoming request has a valid UTF-8 encoded path.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Illuminate\Http\Exceptions\MalformedUrlException
*/
public function handle(Request $request, Closure $next)
{
$decodedPath = rawurldecode($request->path());
if (! mb_check_encoding($decodedPath, 'UTF-8')) {
throw new MalformedUrlException;
}
return $next($request);
}
}