MCPcopy Index your code
hub / github.com/perkeep/perkeep / FileNameString

Method FileNameString

pkg/schema/schema.go:432–448  ·  view source on GitHub ↗

FileNameString returns the schema blob's base filename. If the fileName field of the blob accidentally or maliciously contains a slash, this function returns an empty string instead.

()

Source from the content-addressed store, hash-verified

430// If the fileName field of the blob accidentally or maliciously
431// contains a slash, this function returns an empty string instead.
432func (ss *superset) FileNameString() string {
433 v := ss.FileName
434 if v == "" {
435 v = stringFromMixedArray(ss.FileNameBytes)
436 }
437 if v != "" {
438 if strings.Contains(v, "/") {
439 // Bogus schema blob; ignore.
440 return ""
441 }
442 if strings.Contains(v, "\\") {
443 // Bogus schema blob; ignore.
444 return ""
445 }
446 }
447 return v
448}
449
450func (ss *superset) HasFilename(name string) bool {
451 return ss.FileNameString() == name

Callers 5

HasFilenameMethod · 0.95
FileNameMethod · 0.80
FileNameMethod · 0.80
FileNameMethod · 0.80
FileNameMethod · 0.80

Calls 2

stringFromMixedArrayFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected