From b51445c101fb2a508a36d91ea6df89b6e51307d8 Mon Sep 17 00:00:00 2001 From: mattpass Date: Sat, 26 Jun 2021 22:41:42 +0100 Subject: [PATCH] File must have a text MIME type to be indexed --- lib/indexer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/indexer.php b/lib/indexer.php index 7785abf..2e19729 100644 --- a/lib/indexer.php +++ b/lib/indexer.php @@ -47,10 +47,20 @@ function phpGrep($path, $base) { if (is_dir($filePath)) { $ret .= phpGrep($filePath, $base); } else { - // Check if we should scan within this file, by only considering files that may contain functions & classes + // Check if we should scan within this file, by only considering files that may contain functions & classes... + // Must be in the indexableFileExts list if (false === in_array($filePathExt, $indexableFileExts)) { continue; } + $finfo = "text"; + // Must have a MIME type string starting with "text" + if (function_exists('finfo_open')) { + $finfoMIME = finfo_open(FILEINFO_MIME); + $finfo = finfo_file($finfoMIME, $filePath); + } + if (strpos($finfo, "text")) { + continue; + } // Check if file appears to be the same (same size and mtime), if so, continue as we'll assume it's not changed if (isset($prevIndexData['files'][$filePath]) && $prevIndexData['files'][$filePath]['size'] === stat($filePath)['size'] &&