Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pinc/metarefresh.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ function metarefresh(int $seconds, string $url, string $title = "", string $body
}

// If $allow_external is FALSE and the URL isn't local, redirect the
// user to the homepage.
if (!$allow_external && !str_starts_with($absolute_url, $code_url)) {
// user to the homepage. Local is defined as the URLs having the same
// scheme, host, and port -- ignoring any path.
$absolute_url_parts = parse_url($absolute_url);
$code_url_parts = parse_url($code_url);
if (!$allow_external && !(
($absolute_url_parts["scheme"] == $code_url_parts["scheme"]) &&
($absolute_url_parts["host"] == $code_url_parts["host"]) &&
(($absolute_url_parts["port"] ?? "") == ($code_url_parts["port"] ?? ""))
)) {
$absolute_url = "$code_url/index.php";
}

Expand Down