mirror of
https://github.com/YGGverse/bdoku.git
synced 2026-03-31 09:45:31 +00:00
prevent direct memory access, remove duplicated reader init
This commit is contained in:
parent
525c7e89fa
commit
173191e0b1
1 changed files with 23 additions and 16 deletions
|
|
@ -348,8 +348,11 @@ $server->setHandler(
|
||||||
|
|
||||||
$_uri = isset($matches[1]) ? $matches[1] : '';
|
$_uri = isset($matches[1]) ? $matches[1] : '';
|
||||||
|
|
||||||
|
// File request, get page content
|
||||||
|
if ($path = $filesystem->getPagePathByUri($_uri))
|
||||||
|
{
|
||||||
// Check for cached results
|
// Check for cached results
|
||||||
if ($content = $memory->get($_uri))
|
if ($content = $memory->get($path))
|
||||||
{
|
{
|
||||||
$response->setContent(
|
$response->setContent(
|
||||||
$content
|
$content
|
||||||
|
|
@ -358,9 +361,6 @@ $server->setHandler(
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// File request, get page content
|
|
||||||
else if ($path = $filesystem->getPagePathByUri($_uri))
|
|
||||||
{
|
|
||||||
// Define base URL
|
// Define base URL
|
||||||
$reader->setMacros(
|
$reader->setMacros(
|
||||||
'~URL:base~',
|
'~URL:base~',
|
||||||
|
|
@ -506,7 +506,7 @@ $server->setHandler(
|
||||||
|
|
||||||
// Cache results
|
// Cache results
|
||||||
$memory->set(
|
$memory->set(
|
||||||
$_uri,
|
$path,
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -519,10 +519,17 @@ $server->setHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
// File not found, request directory for minimal navigation
|
// File not found, request directory for minimal navigation
|
||||||
else if ($directory = $filesystem->getDirectoryPathByUri($_uri))
|
else if ($path = $filesystem->getDirectoryPathByUri($_uri))
|
||||||
{
|
{
|
||||||
// Init reader
|
// Check for cached results
|
||||||
$reader = new \Yggverse\Gemini\Dokuwiki\Reader();
|
if ($content = $memory->get($path))
|
||||||
|
{
|
||||||
|
$response->setContent(
|
||||||
|
$content
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
// Init home page content
|
// Init home page content
|
||||||
$lines = [
|
$lines = [
|
||||||
|
|
@ -656,7 +663,7 @@ $server->setHandler(
|
||||||
|
|
||||||
// Cache results
|
// Cache results
|
||||||
$memory->set(
|
$memory->set(
|
||||||
$_uri,
|
$path,
|
||||||
$content
|
$content
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue