ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
WhitelistFileHeaderPreProcessor.php
Go to the documentation of this file.
1<?php
2
4
8use ILIAS\FileUpload\ScalarTypeCheckAware;
10
21{
22 use ScalarTypeCheckAware;
23
27 private $fileHeader;
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
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}
$metadata['__DYNAMIC:1__']
An exception for terminatinating execution or to throw for unit testing.
const REJECTED
Upload got rejected by a processor.
__construct($fileHeader)
WhitelistFileHeaderPreProcessor constructor.
process(FileStream $stream, Metadata $metadata)
@inheritDoc
Describes a data stream.
$stream
PHP stream implementation.