forked from forgejo/forgejo
Restrict repository indexing by file extension
This commit is contained in:
parent
026696b87a
commit
a85393b655
3 changed files with 35 additions and 0 deletions
|
@ -232,6 +232,17 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e
|
|||
}
|
||||
|
||||
func isIndexable(entry *git.TreeEntry) bool {
|
||||
if setting.Indexer.FileExtensions != nil {
|
||||
var ext string
|
||||
parts := strings.Split(entry.Name(), ".")
|
||||
cnt := len(parts)
|
||||
if cnt > 1 {
|
||||
ext = strings.ToLower(parts[cnt-1])
|
||||
}
|
||||
if setting.Indexer.FileExtensions[ext] == setting.Indexer.ExcludeExtensions {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return entry.IsRegular() || entry.IsExecutable()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue