fix: preserve section rule priority
This commit is contained in:
@@ -112,7 +112,7 @@ func (a *Account) maskFor(path string, entry bool) PermMask {
|
|||||||
if entry && r.ChildrenOnly && matchPathExact(d, path) {
|
if entry && r.ChildrenOnly && matchPathExact(d, path) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(d) > best {
|
if len(d) >= best {
|
||||||
best = len(d)
|
best = len(d)
|
||||||
if r.Deny {
|
if r.Deny {
|
||||||
mask = None
|
mask = None
|
||||||
|
|||||||
@@ -91,6 +91,18 @@ func TestSectionRuleSemantics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSectionRuleSamePathPriority(t *testing.T) {
|
||||||
|
a := &Account{Mask: Delete, Rules: []PathRule{
|
||||||
|
{Dir: "secret", Mask: None, Deny: true},
|
||||||
|
{Dir: "secret", Mask: ParseMask("r"), ChildrenOnly: true},
|
||||||
|
{Dir: "secret", Mask: ParseMask("w"), ChildrenOnly: true},
|
||||||
|
{Dir: "secret", Mask: ParseMask("d"), ChildrenOnly: true},
|
||||||
|
}}
|
||||||
|
if got := a.MaskFor("secret/file"); got != ParseMask("d") {
|
||||||
|
t.Fatalf("same-path rule priority=%v", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestWildcardSectionRules(t *testing.T) {
|
func TestWildcardSectionRules(t *testing.T) {
|
||||||
a := &Account{Mask: Read, Rules: []PathRule{{Dir: "project-*", Mask: Write, ChildrenOnly: true}}}
|
a := &Account{Mask: Read, Rules: []PathRule{{Dir: "project-*", Mask: Write, ChildrenOnly: true}}}
|
||||||
if got := a.MaskFor("project-one/file"); got != Write {
|
if got := a.MaskFor("project-one/file"); got != Write {
|
||||||
|
|||||||
Reference in New Issue
Block a user