mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
fix #983
This commit is contained in:
parent
d37af694af
commit
984794eb1e
@ -452,7 +452,7 @@ func (set *UserMaskSet) setRegexp() {
|
|||||||
set.RUnlock()
|
set.RUnlock()
|
||||||
|
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
expr := "^" + strings.Join(maskExprs, "|") + "$"
|
expr := "^(" + strings.Join(maskExprs, "|") + ")$"
|
||||||
re, _ = regexp.Compile(expr)
|
re, _ = regexp.Compile(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,3 +27,32 @@ func BenchmarkGenerateBatchID(b *testing.B) {
|
|||||||
session.generateBatchID()
|
session.generateBatchID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUserMasks(t *testing.T) {
|
||||||
|
var um UserMaskSet
|
||||||
|
|
||||||
|
if um.Match("horse_!user@tor-network.onion") {
|
||||||
|
t.Error("bad match")
|
||||||
|
}
|
||||||
|
|
||||||
|
um.Add("_!*@*", "x", "x")
|
||||||
|
if !um.Match("_!user@tor-network.onion") {
|
||||||
|
t.Error("failure to match")
|
||||||
|
}
|
||||||
|
if um.Match("horse_!user@tor-network.onion") {
|
||||||
|
t.Error("bad match")
|
||||||
|
}
|
||||||
|
|
||||||
|
um.Add("beer*!*@*", "x", "x")
|
||||||
|
if !um.Match("beergarden!user@tor-network.onion") {
|
||||||
|
t.Error("failure to match")
|
||||||
|
}
|
||||||
|
if um.Match("horse_!user@tor-network.onion") {
|
||||||
|
t.Error("bad match")
|
||||||
|
}
|
||||||
|
|
||||||
|
um.Add("horse*!user@*", "x", "x")
|
||||||
|
if !um.Match("horse_!user@tor-network.onion") {
|
||||||
|
t.Error("failure to match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user