File must have a text MIME type to be indexed

This commit is contained in:
mattpass
2021-06-26 22:41:42 +01:00
parent 42d60ea48f
commit b51445c101

View File

@@ -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'] &&