strengthen assertHttpsUrl

This commit is contained in:
stefan.tollkuehn committed 2026-10-08 13:52:03 +02:00
1 parent 9d268c967e
commit 2e3859795f
1 file changed
+11
+11
View File
@@ -535,11 +535,22 @@ class CalendarController extends Controller
private function assertHttpsUrl(string $value, string $message): void
{
/*
* filter_var() plus the regex reject whitespace, backslashes
* and non-ASCII characters: browsers may display those
* differently than PHP parses them, e.g. IDN homographs.
*/
if (filter_var($value, FILTER_VALIDATE_URL) === false
|| preg_match('/[^\x21-\x7E]|\\\\/', $value) === 1) {
throw new \InvalidArgumentException($message);
}
$parts = parse_url($value);
$valid = $parts !== false
&& isset($parts['scheme'], $parts['host'])
&& !isset($parts['user'])
&& !isset($parts['pass'])
&& strtolower($parts['scheme']) === 'https'
&& $parts['host'] !== '';