Browse Source

fix #983

tags/v2.1.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
984794eb1e
2 changed files with 30 additions and 1 deletions
  1. 1
    1
      irc/client_lookup_set.go
  2. 29
    0
      irc/client_test.go

+ 1
- 1
irc/client_lookup_set.go View File

@@ -452,7 +452,7 @@ func (set *UserMaskSet) setRegexp() {
452 452
 	set.RUnlock()
453 453
 
454 454
 	if index > 0 {
455
-		expr := "^" + strings.Join(maskExprs, "|") + "$"
455
+		expr := "^(" + strings.Join(maskExprs, "|") + ")$"
456 456
 		re, _ = regexp.Compile(expr)
457 457
 	}
458 458
 

+ 29
- 0
irc/client_test.go View File

@@ -27,3 +27,32 @@ func BenchmarkGenerateBatchID(b *testing.B) {
27 27
 		session.generateBatchID()
28 28
 	}
29 29
 }
30
+
31
+func TestUserMasks(t *testing.T) {
32
+	var um UserMaskSet
33
+
34
+	if um.Match("horse_!user@tor-network.onion") {
35
+		t.Error("bad match")
36
+	}
37
+
38
+	um.Add("_!*@*", "x", "x")
39
+	if !um.Match("_!user@tor-network.onion") {
40
+		t.Error("failure to match")
41
+	}
42
+	if um.Match("horse_!user@tor-network.onion") {
43
+		t.Error("bad match")
44
+	}
45
+
46
+	um.Add("beer*!*@*", "x", "x")
47
+	if !um.Match("beergarden!user@tor-network.onion") {
48
+		t.Error("failure to match")
49
+	}
50
+	if um.Match("horse_!user@tor-network.onion") {
51
+		t.Error("bad match")
52
+	}
53
+
54
+	um.Add("horse*!user@*", "x", "x")
55
+	if !um.Match("horse_!user@tor-network.onion") {
56
+		t.Error("failure to match")
57
+	}
58
+}

Loading…
Cancel
Save