Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3409,7 +3409,7 @@ func TestDocChecker(t *testing.T) {
t.Errorf("Check(%q): %v", text, skip)
}
}
for _, text := range []string{"zero\x00byte", "xx", "0123456789abcdefghi"} {
for _, text := range []string{"zero\x00byte", "\x00starts with null byte", "xx", "0123456789abcdefghi"} {
if skip := docChecker.Check([]byte(text), 15, false); skip == SkipReasonNone {
t.Errorf("Check(%q) succeeded", text)
}
Expand All @@ -3421,7 +3421,7 @@ func TestDocChecker(t *testing.T) {
t.Errorf("Check(%q): %v", text, skip)
}
}
for _, text := range []string{"zero\x00byte", "xx"} {
for _, text := range []string{"zero\x00byte", "\x00starts with null byte", "xx"} {
if skip := docChecker.Check([]byte(text), 15, true); skip == SkipReasonNone {
t.Errorf("Check(%q) succeeded", text)
}
Expand Down
4 changes: 2 additions & 2 deletions index/shard_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func (b *ShardBuilder) Add(doc Document) error {
// Skip binary check if already computed (e.g., by Builder.Add
// which calls DocChecker.Check before docs reach buildShard).
if doc.Category == FileCategoryMissing {
if index := bytes.IndexByte(doc.Content, 0); index > 0 {
if index := bytes.IndexByte(doc.Content, 0); index >= 0 {
doc.SkipReason = SkipReasonBinary
}
}
Expand Down Expand Up @@ -686,7 +686,7 @@ func (t *DocChecker) Check(content []byte, maxTrigramCount int, allowLargeFile b
return SkipReasonTooSmall
}

if index := bytes.IndexByte(content, 0); index > 0 {
if index := bytes.IndexByte(content, 0); index >= 0 {
return SkipReasonBinary
}

Expand Down