@@ -96,8 +96,8 @@ func CheckACLPermission(ctx context.Context, path string, requiredPerm int32) (*
9696 continue
9797 }
9898
99- // Check if path matches the rule
100- if pathMatches (normalizedPath , rule .Path ) {
99+ // Check if path matches the rule, considering ExcludeSubfolder
100+ if pathMatchesWithSubfolder (normalizedPath , rule .Path , ! rule . ExcludeSubfolder ) {
101101 if matchedRule == nil || rule .Priority > matchedRule .Priority {
102102 matchedRule = & rule
103103 }
@@ -185,7 +185,7 @@ func GetMatchedACLRule(ctx context.Context, path string) (*model.ACLMatchedRule,
185185 continue
186186 }
187187
188- if pathMatches (normalizedPath , rule .Path ) {
188+ if pathMatchesWithSubfolder (normalizedPath , rule .Path , ! rule . ExcludeSubfolder ) {
189189 if matchedRule == nil || rule .Priority > matchedRule .Priority {
190190 matchedRule = & rule
191191 }
@@ -257,28 +257,18 @@ func normalizePath(path string) string {
257257 return path
258258}
259259
260- func pathMatches ( path , pattern string ) bool {
261- // Normalize both paths
260+ // pathMatchesWithSubfolder checks if path matches pattern, with subfolder option
261+ func pathMatchesWithSubfolder ( path , pattern string , includeSubfolder bool ) bool {
262262 path = normalizePath (path )
263263 pattern = normalizePath (pattern )
264264
265- // Exact match
266265 if path == pattern {
267266 return true
268267 }
269-
270- // Pattern with wildcard
271- if strings .HasSuffix (pattern , "/*" ) {
272- prefix := strings .TrimSuffix (pattern , "/*" )
268+ if includeSubfolder {
273269 // Check if path is under this directory
274- return strings .HasPrefix (path , prefix + "/" ) || path == prefix
270+ return strings .HasPrefix (path , pattern + "/" ) || path == pattern
275271 }
276-
277- // Pattern is a parent directory
278- if strings .HasPrefix (path , pattern + "/" ) {
279- return true
280- }
281-
282272 return false
283273}
284274
0 commit comments