Opened 18 years ago
Closed 16 years ago
#5050 closed defect (fixed)
Attachments made against Wiki pages with colons in their names end up in the wrong place.
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 0.11.2 |
Component: | attachment | Version: | |
Severity: | minor | Keywords: | attachment |
Cc: | osimons | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
A file attached to the wiki page 'Foo:Bar', will end up being attached to 'Foo/Bar'. It looks like this bug is a side-effect of this patch:
http://trac.edgewall.org/changeset/3019
An easy way to recreate this is to just attempt to attach a file to a page with a colon in it. The 'Add Attachment …' page shows the colon replaced with a forward slash.
Attachments (0)
Change History (12)
comment:1 by , 18 years ago
Keywords: | attachment added |
---|---|
Milestone: | → 0.12 |
Severity: | normal → minor |
comment:2 by , 17 years ago
Milestone: | 0.12 → 0.11.1 |
---|
Still a problem with current 0.11b1+. From my brief tests that [3019] changeset does look like the cause of it. It is there for other reasons though, so need to work out a solution that keeps all things working.
It is a bit unfortunate that Wiki and Attachment handle this differently, also as it involves storing files in a structure on disk that is wrong.
I'm rescheduling it, hopefully finding a fix in the 0.11.x line.
comment:3 by , 17 years ago
Component: | wiki → attachment |
---|
comment:5 by , 16 years ago
Here's an update on the current situation:
- The fix in [3019] was intended for accepting InterTrac links generated with
.compat = true
in TracIni, which look like/attachment/wiki:WikiStart:file.txt
. In that case, replacing ':' with '/' conveniently fixes the path to the attachment.
- This fix was broken in [4246], where the realm part of the regexp has been changed from
(wiki|ticket)
to([^/]+)
, which in this case matches the complete path instead of only "wiki". The path ends up empty.
The latter breakage could be fixed by taking the realm to be the string up to the first '/' or ':'. But fixing the original problem is not possible, as there is an ambiguity in the URL.
OTOH, this also means that since [4246] (21 months ago, 0.10.2), support for InterTrac links in compatibility mode has been broken, and this has never been reported. This probably means that there are few 0.9 instances pointing to ≥0.10 instances through InterTrac.
I propose dropping support for <0.10 attachment InterTrac links by reverting the fix in [3019] as follows:
-
trac/attachment.py
diff --git a/trac/attachment.py b/trac/attachment.py
a b 345 345 # IRequestHandler methods 346 346 347 347 def match_request(self, req): 348 match = re.match(r'^/(raw-)?attachment/([^/]+)(?: [/:](.*))?$',348 match = re.match(r'^/(raw-)?attachment/([^/]+)(?:/(.*))?$', 349 349 req.path_info) 350 350 if match: 351 351 raw, realm, path = match.groups() … … 353 353 req.args['format'] = 'raw' 354 354 req.args['realm'] = realm 355 355 if path: 356 req.args['path'] = path .replace(':', '/')356 req.args['path'] = path 357 357 return True 358 358 359 359 def process_request(self, req):
Comments?
comment:6 by , 16 years ago
Nice - tested the fix and it works well for the attachment side of things.
Personally I'd rather have this serious attachment bug fixed, than support a special case from the early days of InterTrac that do not seem to be extensively used. However, should really get feedback from cboos or other 'old-timers' before committing - especially as it modifies behaviour in a stable branch.
comment:7 by , 16 years ago
Cc: | added |
---|
comment:8 by , 16 years ago
Milestone: | 0.11.3 → 0.11.2 |
---|
Edging this one step closer to making next release - pending review.
comment:10 by , 16 years ago
Fix looks good, I also think we can safely drop support for the compatibility mode here for 0.11.2 and perhaps remove any code related to this compatibility mode for 0.12, in case you find some more.
In the unlikely case there would be a problem (a "source" Trac incorrectly targeting a recent Trac in compatibility mode), it's a simple setting to change on that source Trac (setting compatibility mode to false
). Since r6151 (before pre-0.11b1), compatibility mode is turned off by default anyway.
comment:11 by , 16 years ago
Owner: | changed from | to
---|
Thanks for the review. I'll apply the patch shortly.
Ok, thanks for the report.