ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
BlacklistFileHeaderPreProcessor.php
Go to the documentation of this file.
1
<?php
2
3
namespace
ILIAS\FileUpload\Processor
;
4
5
use
ILIAS\Filesystem\Stream\FileStream
;
6
use
ILIAS\FileUpload\DTO\Metadata
;
7
use
ILIAS\FileUpload\DTO\ProcessingStatus
;
8
use
ILIAS\FileUpload\ScalarTypeCheckAware
;
9
use
Psr\Http\Message\StreamInterface
;
10
20
final
class
BlacklistFileHeaderPreProcessor
implements
PreProcessor
21
{
22
use
ScalarTypeCheckAware
;
23
27
private
$fileHeader
;
31
private
$fileHeaderLength
;
32
33
39
public
function
__construct
(
$fileHeader
)
40
{
41
$this->stringTypeCheck(
$fileHeader
,
'fileHeader'
);
42
43
$this->fileHeaderLength = strlen(
$fileHeader
);
44
$this->fileHeader =
$fileHeader
;
45
}
46
47
51
public
function
process
(
FileStream
$stream
,
Metadata
$metadata
)
52
{
53
$header
= $stream->
read
($this->fileHeaderLength);
54
if
(strcmp($this->fileHeader,
$header
) !== 0) {
55
return
new
ProcessingStatus
(
ProcessingStatus::OK
,
'File header does not match blacklist.'
);
56
}
57
58
return
new
ProcessingStatus
(
ProcessingStatus::REJECTED
,
'File header matches blacklist.'
);
59
}
60
}
ILIAS\FileUpload\Processor\PreProcessor
Class PreProcessor.
Definition:
PreProcessor.php:22
ILIAS\FileUpload\DTO\ProcessingStatus
Class ProcessingStatus.
Definition:
ProcessingStatus.php:20
ILIAS\FileUpload\DTO\ProcessingStatus\REJECTED
const REJECTED
Upload got rejected by a processor.
Definition:
ProcessingStatus.php:30
Psr\Http\Message\StreamInterface\read
read($length)
Read data from the stream.
ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessor\process
process(FileStream $stream, Metadata $metadata)
Definition:
BlacklistFileHeaderPreProcessor.php:51
ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessor\__construct
__construct($fileHeader)
BlacklistFileHeaderPreProcessor constructor.
Definition:
BlacklistFileHeaderPreProcessor.php:39
ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessor\$fileHeader
$fileHeader
Definition:
BlacklistFileHeaderPreProcessor.php:27
$header
$header
Definition:
no_cookie.tpl.php:6
$metadata
$metadata['__DYNAMIC:1__']
Definition:
adfs-idp-hosted.php:3
GuzzleHttp\Psr7\$stream
$stream
PHP stream implementation.
Definition:
MessageTrait.php:21
ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessor
Class BlacklistFileHeaderPreProcessor.
Definition:
BlacklistFileHeaderPreProcessor.php:20
ProcessingStatus
ILIAS\FileUpload\Processor\BlacklistFileHeaderPreProcessor\$fileHeaderLength
$fileHeaderLength
Definition:
BlacklistFileHeaderPreProcessor.php:31
ScalarTypeCheckAware
ILIAS\FileUpload\Processor
Definition:
BlacklistExtensionPreProcessor.php:3
ILIAS\FileUpload\DTO\Metadata
Class Metadata.
Definition:
Metadata.php:21
StreamInterface
Metadata
ScalarTypeCheckAware
FileStream
ILIAS\Filesystem\Stream\FileStream
Interface FileStream.
Definition:
FileStream.php:20
ILIAS\FileUpload\DTO\ProcessingStatus\OK
const OK
Upload is ok.
Definition:
ProcessingStatus.php:26
src
FileUpload
Processor
BlacklistFileHeaderPreProcessor.php
Generated on Sat Jan 18 2025 19:01:42 for ILIAS by
1.8.13 (using
Doxyfile
)