Opened 19 years ago
Closed 19 years ago
#1705 closed defect (fixed)
Attachment fail on Win32 without normalization of env.path
Reported by: | Owned by: | Christopher Lenz | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I think that the value of Environment.path should be normalized nortation like 'c:\trac\project' not 'c:/trac/project' on windows environment. This style like 'c:/dir/dir' is usual in httpd.conf but it would cuase unexpected result of os.path.commonprefix() used in attachment.py. Thus adding attachement would fail.
Index: env.py =================================================================== --- env.py (revision 1846) +++ env.py (working copy) @@ -78,7 +78,7 @@ except ImportError: pass - self.path = path + self.path = os.path.normpath(path) self.__cnx_pool = None if create: self.create(db_str)
Attachments (0)
Change History (4)
comment:1 by , 19 years ago
Milestone: | → 0.9 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 19 years ago
comment:3 by , 19 years ago
Priority: | normal → high |
---|
Maybe a TracError would be usefull. I think many people get shock if their configuration that was working fine for month stops working after doing an update.
Index: attachment.py =================================================================== --- attachment.py (revision 1862) +++ attachment.py (working copy) @@ -122,7 +122,10 @@ # attachments directory attachments_dir = os.path.join(self.env.path, 'attachments') commonprefix = os.path.commonprefix([attachments_dir, self.path]) - assert commonprefix == attachments_dir + if not commonprefix == attachments_dir: + raise TracError('Common prefix (%s) of attachments_dir (%s) and self.path (%s) not ok' % + (commonprefix,attachments_dir,self.path), + 'Attachment failed. Check TracEnv!' ); if not os.access(self.path, os.F_OK): os.makedirs(self.path)
comment:4 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I had to make a quick fix for this, in preparation for other changes in attachment.py. I didn't modify env.py as suggested by the reporter, but instead fixed that particular failure in attachment.py: That way, it's less likely to introduce unwanted side-effects…
(see [1865])
#1719 has been marked as a duplicate of this ticket.