ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
WhitelistFileHeaderPreProcessor.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
WhitelistFileHeaderPreProcessor
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 complies with whitelist.'
);
56
}
57
58
return
new
ProcessingStatus
(
ProcessingStatus::REJECTED
,
'File header don\'t complies with whitelist.'
);
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\WhitelistFileHeaderPreProcessor\__construct
__construct($fileHeader)
WhitelistFileHeaderPreProcessor constructor.
Definition:
WhitelistFileHeaderPreProcessor.php:39
ILIAS\FileUpload\Processor\WhitelistFileHeaderPreProcessor\$fileHeader
$fileHeader
Definition:
WhitelistFileHeaderPreProcessor.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\WhitelistFileHeaderPreProcessor\process
process(FileStream $stream, Metadata $metadata)
Definition:
WhitelistFileHeaderPreProcessor.php:51
ProcessingStatus
ScalarTypeCheckAware
ILIAS\FileUpload\Processor
Definition:
BlacklistExtensionPreProcessor.php:3
ILIAS\FileUpload\DTO\Metadata
Class Metadata.
Definition:
Metadata.php:21
StreamInterface
ILIAS\FileUpload\Processor\WhitelistFileHeaderPreProcessor
Class WhitelistFileHeaderPreProcessor.
Definition:
WhitelistFileHeaderPreProcessor.php:20
Metadata
ScalarTypeCheckAware
FileStream
php
ILIAS\FileUpload\Processor\WhitelistFileHeaderPreProcessor\$fileHeaderLength
$fileHeaderLength
Definition:
WhitelistFileHeaderPreProcessor.php:31
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
WhitelistFileHeaderPreProcessor.php
Generated on Thu Jan 16 2025 19:02:37 for ILIAS by
1.8.13 (using
Doxyfile
)