Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

#1705 closed defect (fixed)

Attachment fail on Win32 without normalization of env.path

Reported by: Shun-ichi Goto <gotoh@…> 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 Christopher Lenz, 20 years ago

Milestone: 0.9
Owner: changed from Jonas Borgström to Christopher Lenz
Status: newassigned

comment:2 by Matthew Good, 20 years ago

#1719 has been marked as a duplicate of this ticket.

comment:3 by PBruin, 20 years ago

Priority: normalhigh

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 Christian Boos, 20 years ago

Resolution: fixed
Status: assignedclosed

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])

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


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