Skip to content

Commit

Permalink
fix: handle zero length file case in loadKeywordsFromFile function (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Tristan Feldbusch <[email protected]>
  • Loading branch information
trifel and Tristan Feldbusch authored Feb 23, 2024
1 parent 4f9fa70 commit 9679fac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
* handle zero length file case in loadKeywordsFromFile function

## [2.10.2] - 2023-10-16
### Fixed
Expand Down
3 changes: 2 additions & 1 deletion src/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,8 @@ protected function loadKeywordsFromFile($file)
);
}

$keywordsFromFile = explode("\n", @fread($cacheFile, filesize($file)));
$filesize = filesize($file);
$keywordsFromFile = $filesize > 0 ? explode("\n", @fread($cacheFile, $filesize)) : array();
@fclose($cacheFile);

/* @phpstan-ignore-next-line */
Expand Down

0 comments on commit 9679fac

Please sign in to comment.