Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-dom": "*",
"ext-libxml": "*",
"brotkrueml/twig-codehighlight": "^1.0",
"league/flysystem": "^1.1.10",
"league/flysystem": "^3.29",
"phpdocumentor/dev-server": "^1.9.4",
"phpdocumentor/filesystem": "^1.9",
"phpdocumentor/guides": "^1.9",
Expand Down
157 changes: 100 additions & 57 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions packages/typo3-docs-theme/src/Directives/IncludeDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public function processNode(
}


/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function resolveGlobInclude(BlockContext $blockContext, string $inputPath, Directive $directive): LiteralBlockNode|CollectionNode|CodeNode
{
$parserContext = $blockContext->getDocumentParserContext()->getParser()->getParserContext();
Expand Down Expand Up @@ -103,9 +100,6 @@ public function resolveGlobInclude(BlockContext $blockContext, string $inputPath
return new CollectionNode($nodes);
}

/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function resolveBasicInclude(BlockContext $blockContext, string $inputPath, Directive $directive): LiteralBlockNode|CollectionNode|CodeNode
{
$parserContext = $blockContext->getDocumentParserContext()->getParser()->getParserContext();
Expand All @@ -121,9 +115,6 @@ public function resolveBasicInclude(BlockContext $blockContext, string $inputPat
return $this->getCollectionFromPath($origin, $path, $directive, $blockContext);
}

/**
* @throws \League\Flysystem\FileNotFoundException
*/
public function getCollectionFromPath(\League\Flysystem\FilesystemInterface|\phpDocumentor\FileSystem\FileSystem $origin, string $path, Directive $directive, BlockContext $blockContext): LiteralBlockNode|CollectionNode|CodeNode
{
$contents = $origin->read($path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public function processNode(
}

/**
* @throws \League\Flysystem\FileNotFoundException
* @throws FileLoadingException
*/
public function loadFileFromDocumentation(BlockContext $blockContext, string $filename): string
Expand Down
35 changes: 19 additions & 16 deletions packages/typo3-docs-theme/src/EventListeners/CopyResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

namespace T3Docs\Typo3DocsTheme\EventListeners;

use League\Flysystem\Adapter\Local;
use League\Flysystem\FilesystemException;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use phpDocumentor\Guides\Event\PostRenderProcess;
use Psr\Log\LoggerInterface;
use Symfony\Component\Finder\Finder;
Expand Down Expand Up @@ -35,29 +36,31 @@ public function __invoke(PostRenderProcess $event): void
return;
}

$source = new Filesystem(new Local($fullResourcesPath));
$source = new Filesystem(new LocalFilesystemAdapter($fullResourcesPath));

/** @var \League\Flysystem\FilesystemInterface */
$destination = $event->getCommand()->getDestination();

$finder = new Finder();
$finder->files()->in($fullResourcesPath);

foreach ($finder as $file) {
$stream = $source->readStream($file->getRelativePathname());
if ($stream === false) {
$this->logger->warning(sprintf('Cannot read stream from "%s"', $file->getRealPath()));
continue;
$stream = null;
try {
$stream = $source->readStream($file->getRelativePathname());
$destinationPath = sprintf(
'%s/%s%s',
self::DESTINATION_PATH,
$file->getRelativePath() !== '' ? $file->getRelativePath() . '/' : '',
$file->getFilename()
);
$destination->putStream($destinationPath, $stream);
} catch (FilesystemException $e) {
$this->logger->warning(sprintf('Cannot copy resource "%s": %s', $file->getRealPath(), $e->getMessage()));
} finally {
if (is_resource($stream)) {
fclose($stream);
}
}

$destinationPath = sprintf(
'%s/%s%s',
self::DESTINATION_PATH,
$file->getRelativePath() !== '' ? $file->getRelativePath() . '/' : '',
$file->getFilename()
);
$destination->putStream($destinationPath, $stream);
is_resource($stream) && fclose($stream);
}
}
}
4 changes: 2 additions & 2 deletions packages/typo3-docs-theme/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace T3Docs\Typo3DocsTheme\Twig;

use League\Flysystem\Exception;
use League\Flysystem\FilesystemException;
use LogicException;
use phpDocumentor\Guides\Nodes\AnchorNode;
use phpDocumentor\Guides\Nodes\DocumentTree\DocumentEntryNode;
Expand Down Expand Up @@ -617,7 +617,7 @@ private function copyAsset(
$renderContext->getLoggerInformation(),
);
}
} catch (LogicException|Exception $e) {
} catch (LogicException|FilesystemException $e) {
$this->logger->error(
sprintf('Unable to write file "%s", %s', $outputPath, $e->getMessage()),
$renderContext->getLoggerInformation(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path is outside of the defined root, path: [/../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml] {"rst-file":"index.rst","currentLineNumber":1} []
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path traversal detected: /../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml {"rst-file":"index.rst","currentLineNumber":1} []
Original file line number Diff line number Diff line change
@@ -1 +1 @@
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path is outside of the defined root, path: [/../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml] {"rst-file":"index.rst","currentLineNumber":1} []
app.ERROR: Error while processing "typo3:site-set-settings" directive in "index": Path traversal detected: /../../../tests/Integration/tests/site-set/input/_includes/Sets/FluidStyledContent/settings.definitions.yaml {"rst-file":"index.rst","currentLineNumber":1} []