Edgewall Software
Modify

Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#1802 closed defect (fixed)

attachment link on WikiStart page

Reported by: Shun-ichi Goto <gotoh@…> Owned by:
Priority: normal Milestone: 0.9
Component: wiki system Version: devel
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

When I accessing WikiStart page without explicit wiki pagename like: http://trac.my.local.net/trac or http://trac.my.local.net/trac/wiki, the rendering of attachment link for current page (like [attachment:file text]) will cause "Index out of range" exception at attachment.py:456.

I made temporary fix for myself as bellow, but I don't know right way to fix.

--- attachment.py	(revision 1986)
+++ attachment.py	(working copy)
@@ -452,8 +452,9 @@
             # FIXME: the formatter should know to which object belongs
             #        the text being formatted
             #        (this info will also be required for TracCrossReferences)
-            path_info = formatter.req.path_info.split('/',2)
-            parent_type, parent_id = path_info[1], path_info[2] # Kludge for now
+            path_info = formatter.req.path_info.split('/',2) + [None, None]
+            parent_type = path_info[1] or 'wiki'
+            parent_id = path_info[2] or 'WikiStart'
             filename = link
         try:
             attachment = Attachment(self.env, parent_type, parent_id, filename)

(I'm using r1986)

Attachments (0)

Change History (5)

comment:1 by Christian Boos, 15 years ago

Milestone: 0.9
Owner: changed from Jonas Borgström to Christian Boos
Priority: normalhigh
Severity: normalminor
Status: newassigned

Yes, that was an oversight.

comment:2 by Christian Boos, 15 years ago

Resolution: fixed
Status: assignedclosed

I applied your patch in r1998.

In the future, the Formatters will know to which Trac object the wiki text to be formatted belongs, and then this code will be cleaned-up.

comment:3 by Matthew Good, 15 years ago

Resolution: fixed
Status: closedreopened

Instead of this admitted kludge, why not simply send a redirect to the WikiStart page when no Wiki page is specified.

comment:4 by Christian Boos, 15 years ago

Milestone: 0.9
Owner: Christian Boos removed
Priority: highnormal
Status: reopenednew

Well, I see that this would solve the issue for links like:

http://trac.my.local.net/trac/wiki

but not for links like:

http://trac.my.local.net/trac

comment:5 by Christopher Lenz, 14 years ago

Milestone: 0.9
Resolution: fixed
Status: newclosed

I think the fix applied here is good enough for now.

If we started redirecting, we'd also need to redirect requests to the main page to the default module, as cboos points out, and that's kind of ugly IMHO.

Modify Ticket

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