Integrate Dokuwiki ACL for file endpoint

This commit is contained in:
2026-01-09 11:13:12 +01:00
parent 23a50ce4f6
commit c11d9bdb8c
14 changed files with 91 additions and 138 deletions

View File

@@ -562,10 +562,37 @@ class Output
*/
protected function itemWebUrl($item, $cachbuster = false)
{
if (str_ends_with($this->webdir, '=')) {
$url = $this->webdir . rawurlencode($item['local']);
$webdir = $this->webdir;
// When using the built-in file-serving endpoint, include the current page id
// so file.php can enforce DokuWiki ACLs for that page.
if (
is_string($webdir)
&& $webdir !== ''
&& strpos($webdir, 'lib/plugins/luxtools/file.php') !== false
&& strpos($webdir, 'id=') === false
) {
global $ID;
$pageId = isset($ID) ? (string)$ID : '';
if ($pageId !== '') {
if (function_exists('cleanID')) {
$pageId = (string)cleanID($pageId);
}
if ($pageId !== '') {
$encoded = rawurlencode($pageId);
if (strpos($webdir, '&file=') !== false) {
$webdir = str_replace('&file=', '&id=' . $encoded . '&file=', $webdir);
} elseif (strpos($webdir, '?file=') !== false) {
$webdir = str_replace('?file=', '?id=' . $encoded . '&file=', $webdir);
}
}
}
}
if (str_ends_with($webdir, '=')) {
$url = $webdir . rawurlencode($item['local']);
} else {
$url = $this->webdir . $item['local'];
$url = $webdir . $item['local'];
}
if ($cachbuster) {