-
Notifications
You must be signed in to change notification settings - Fork 16
Windows: redirect pattern matching fails for glob patterns with subdirectories #123
Description
Description
On Windows, redirect rules using ** glob patterns with subdirectories fail to match because of a slash mismatch between the normalized pattern and the target path.
For example, these rules don't work on Windows:
deny-redirect ~/** "Block home dir" # ✅ works
allow-redirect ~/repos/** # ❌ broken
deny-redirect ./src/** # ❌ broken
Root Cause
In src/dippy/core/config.py, _normalize_redirect_pattern (line ~689) splits the pattern at ** and normalizes the prefix via Path.resolve(), which converts all slashes to backslashes on Windows.
However, _HOME expansion in _expand_token (line ~475) uses str(Path.home()) + token[1:], which preserves the original forward slashes from the shell input.
This creates a mismatch:
- Pattern regex:
C:\Users\YYY\repos\**→C:\Users\YYY\repos\.* - Target path:
C:\Users\YYY/repos/test.txt
The backslash \ in the regex doesn't match the forward slash / in the target.
Reproduction
# ~/.dippy/config
deny-redirect ~/** "Block home"
allow-redirect ~/repos/**
# Test (on Windows with git bash)
echo '{"tool_name":"Bash","tool_input":{"command":"echo test > ~/repos/test.txt","cwd":"/c/Users/YYY"}}' | dippy.exe
# Expected: allow (~/repos/** overrides ~/**)
# Actual: deny (~/** wins because ~/repos/** never matches)Affected patterns
Any ** redirect pattern with subdirectories on Windows:
allow-redirect ~/repos/**deny-redirect ./src/**allow-redirect ./dist/**
Simple ~/** works because the split happens before any subdirectory slash.
Suggested fix
Normalize slashes consistently in _normalize_redirect_pattern — either always use forward slashes in both pattern and target, or normalize both to os.sep.