Edgewall Software
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)

Change History (1)

comment:1 by AhmedMahfouz, 9 hours ago

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.