Edgewall Software

Ticket #5050 (new defect)

Opened 17 months ago

Last modified 11 days ago

Attachments made against Wiki pages with colons in their names end up in the wrong place.

Reported by: alexander@… Owned by: cboos
Priority: normal Milestone: 0.11.3
Component: attachment Version:
Severity: minor Keywords: attachment
Cc:

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

Change History

Changed 17 months ago by cboos

  • keywords attachment added
  • severity changed from normal to minor
  • milestone set to 0.12

Ok, thanks for the report.

Changed 7 months ago by osimons

  • milestone changed from 0.12 to 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.

Changed 7 months ago by cboos

  • component changed from wiki to attachment

Changed 5 weeks ago by osimons

#7462 closed as duplicate.

Changed 12 days ago by rblank

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?

Changed 11 days ago by osimons

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.

Add/Change #5050 (Attachments made against Wiki pages with colons in their names end up in the wrong place.)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change. Next status will be 'new'
The owner will change to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.