fix(wildcard): check name length (#1758)

* fix(wildcard): check name length

* fix(wildcard): add additional test

* fix(wildcard): tests

---------

Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
Kyle Sanderson 2024-10-07 06:55:26 -07:00 committed by GitHub
parent d15b61870e
commit a64fd779f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -55,7 +55,7 @@ func match(pattern, name string, simple bool) (matched bool) {
}
offset := base + i
if name[base:offset] != pattern[base:offset] {
if len(name) < offset || name[base:offset] != pattern[base:offset] {
break
}

View file

@ -102,6 +102,11 @@ func TestMatch(t *testing.T) {
text: "The God of the BrrThe Power of Brr",
matched: true,
},
{
pattern: "mysteries?of?the?abandoned*",
text: "them",
matched: false,
},
}
// Iterating over the test cases, call the function under test and assert the output.
for i, testCase := range testCases {