Browse Source

Fix invalid slice indexing

- Advancing too far resulted in failure to match or index out of range.
Rod Hynes 4 years ago
parent
commit
572610867b
2 changed files with 3 additions and 1 deletions
  1. 1 1
      psiphon/common/wildcard/wildcard.go
  2. 2 0
      psiphon/common/wildcard/wildcard_test.go

+ 1 - 1
psiphon/common/wildcard/wildcard.go

@@ -114,7 +114,7 @@ func Match(pattern, target string) bool {
 				}
 
 				pattern = pattern[i+1:]
-				target = target[j+i+1:]
+				target = target[j+i:]
 			}
 
 		}

+ 2 - 0
psiphon/common/wildcard/wildcard_test.go

@@ -42,6 +42,8 @@ func TestMatch(t *testing.T) {
 		{"Lorem*dolor*eiusmod*magna*", target, true},
 		{"*ipsum*elit*aliqua.", target, true},
 		{"Lorem*dolor*eiusmod*dolore*aliqua.", target, true},
+		{"*dolor* sit*", target, true},
+		{"*aliqua.*", target, true},
 
 		{"", target, false},
 		{"L-rem*", target, false},