Skip to content
Open
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
8 changes: 7 additions & 1 deletion Sources/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@ public function __construct(
// Resolving the canonical path of both the file and the
// directories is important in order to ensure that we
// don't end up navigating outside the avatar dirs.
// A forum at the root of its domain has no path of its
// own to strip. Url::$path is typed with no default, so
// it is not there to be read at all in that case, and
// reading it throws rather than giving back ''.
$board_path = Url::create(Config::$boardurl)->path ?? '';

$abs_path = Sapi::canonicalPath(
preg_replace('~^' . preg_quote(Url::create(Config::$boardurl)->path, '~') . '~u', '', $url->path),
preg_replace('~^' . preg_quote($board_path, '~') . '~u', '', $url->path),
base_dir: Config::$boarddir,
);

Expand Down