Edgewall Software
Modify

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: alexander@… 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 Christian Boos, 18 years ago

Keywords: attachment added
Milestone: 0.12
Severity: normalminor

Ok, thanks for the report.

comment:2 by osimons, 17 years ago

Milestone: 0.120.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 Christian Boos, 17 years ago

Component: wikiattachment

comment:4 by osimons, 16 years ago

#7462 closed as duplicate.

comment:5 by Remy Blank, 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  
    345345    # IRequestHandler methods
    346346
    347347    def match_request(self, req):
    348         match = re.match(r'^/(raw-)?attachment/([^/]+)(?:[/:](.*))?$',
     348        match = re.match(r'^/(raw-)?attachment/([^/]+)(?:/(.*))?$',
    349349                         req.path_info)
    350350        if match:
    351351            raw, realm, path = match.groups()
     
    353353                req.args['format'] = 'raw'
    354354            req.args['realm'] = realm
    355355            if path:
    356                 req.args['path'] = path.replace(':', '/')
     356                req.args['path'] = path
    357357            return True
    358358
    359359    def process_request(self, req):

Comments?

comment:6 by osimons, 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 osimons, 16 years ago

Cc: osimons added

comment:8 by osimons, 16 years ago

Milestone: 0.11.30.11.2

Edging this one step closer to making next release - pending review.

comment:9 by Remy Blank, 16 years ago

Christian, would you mind taking a quick look a this one (comment:5)?

comment:10 by Christian Boos, 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 Remy Blank, 16 years ago

Owner: changed from Christian Boos to Remy Blank

Thanks for the review. I'll apply the patch shortly.

comment:12 by Remy Blank, 16 years ago

Resolution: fixed
Status: newclosed

Patch committed in [7546].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank 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.