If the line is just "#include" with nothing following it we would crash with an index out of bounds error. Now it's a little more careful.
This commit is contained in:
@@ -1079,3 +1079,22 @@ func TestSpecialChars(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartialIncludeLine(t *testing.T) {
|
||||
// Loading a partial #include line (no file mentioned) should error but not crash.
|
||||
|
||||
pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "."), WithCache(true))
|
||||
cases := []string{
|
||||
"#include",
|
||||
"#include\n",
|
||||
"#include ",
|
||||
"#include \n",
|
||||
"#include \n\n\n",
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
if err := pats.Parse(bytes.NewBufferString(tc), ".stignore"); err == nil {
|
||||
t.Fatal("should error out")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user