Modify ↓
Opened 9 hours ago
Last modified 9 hours ago
#13896 new defect
Util: fix is_path_below() when parent is root path
| Reported by: | AhmedMahfouz | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | general | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
Summary
This PR fixes an edge case in trac.util.is_path_below() when the parent path is a filesystem root.
Problem
The previous implementation used string prefix matching:
path == parent or path.startswith(parent + os.sep)
This fails for root parents (for example / on POSIX, and drive roots on Windows), because appending os.sep to a root path does not produce a reliable boundary check.
Solution
Replaced the prefix check with os.path.commonpath(...).
Tests
Added a regression test in PathTestCase:
Attachments (0)
Note:
See TracTickets
for help on using tickets.



The link for the ticket can be found in https://github.com/edgewall/trac/pull/28