Edgewall Software

Opened 10 years ago

Last modified 10 years ago

#11528 closed defect

Should not use fnmatch which is platform dependent — at Initial Version

Reported by: Jun Omae Owned by:
Priority: normal Milestone: 1.0.2
Component: general Version:
Severity: normal Keywords: authzpolicy windows
Cc: Ryan J Ollos Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Trac core uses fnmatch.fnmatch method. The method internally use os.path.normcase and is depended on platform. I don't think we should use the methods for wildcard-globbing.

We should use fnmatch.translate instead.

Windows:

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from fnmatch import fnmatch
>>> fnmatch('abc/def', r'a*/def')
True
>>> fnmatch('abc/def', r'a*\def')
True
>>> fnmatch('abc/def', r'a*\DEF')
True

Linux:

Python 2.4.3 (#1, Jan  9 2013, 06:49:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from fnmatch import fnmatch
>>> fnmatch('abc/def', 'a*/def')
True
>>> fnmatch('abc/def', r'a*\def')
False
$ grep -wr --include='*.py' fnmatch trac tracopt
trac/versioncontrol/web_ui/browser.py:from fnmatch import fnmatchcase
trac/wiki/macros.py:from fnmatch import fnmatchcase
trac/web/main.py:import fnmatch
trac/web/main.py:                 and not any(fnmatch.fnmatch(path[:-1], pattern)
tracopt/perm/authz_policy.py:from fnmatch import fnmatch
tracopt/perm/authz_policy.py:            if fnmatch(resource_key, resource_glob):

Change History (0)

Note: See TracTickets for help on using tickets.