Fully ensure all URL components are present for rewriting

This commit is contained in:
Joshua Ramon Enslin 2023-11-05 23:37:28 +01:00
parent ae12cfdf0f
commit 5c2c1a47cc
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -203,7 +203,7 @@ final class MD_STD_IN {
}
}
catch (MDInvalidUrl $e) {
if (($parsed = parse_url($input)) === false || empty($parsed['scheme'])) {
if (($parsed = parse_url($input)) === false || empty($parsed['scheme']) || empty($parsed['host']) || empty($parsed['path'])) {
throw new MDInvalidUrl("Invalid input URL");
}
$rewritten = $parsed['scheme'] . '://';
@ -219,6 +219,8 @@ final class MD_STD_IN {
}
}
if (empty($output)) return '';
// Check for valid schemes
if (MD_STD::startsWithAny($output, ['https://', 'http://', 'ftp://']) === false) {
throw new MDInvalidUrl("Invalid input URL");