Skip to content

Commit

Permalink
Support PHP wrappers (e.g. data://) (#72)
Browse files Browse the repository at this point in the history
* drop use of is_readable which isn't compatible with wrappers (https://www.php.net/manual/en/wrappers.php).

* check stream instead of file
  • Loading branch information
bdelamatre authored Jul 23, 2024
1 parent 303ce51 commit 4d74b48
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ClamavValidator/ClamavValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ public function validateClamav(string $attribute, $value, array $parameters): bo
protected function validateFileWithClamAv($value): bool
{
if (is_resource($value)) {
$file = $value;
$stream = $value;
} else {
$file = $this->getFilePath($value);
if (! is_readable($file)) {
$stream = fopen($file, 'rb');
if ($stream === false) {
throw ClamavValidatorException::forNonReadableFile($file);
}
}

try {
$socket = $this->getClamavSocket();
$scanner = $this->createQuahogScannerClient($socket);
$stream = is_resource($file) ? $file : fopen($file, 'rb');
$result = $scanner->scanResourceStream($stream);
} catch (Exception $exception) {
if (Config::get('clamav.client_exceptions')) {
Expand Down

0 comments on commit 4d74b48

Please sign in to comment.