Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8953 closed defect (duplicate)

Absolute href are broken if trac is installed in root path

Reported by: anonymous Owned by: cbalan
Priority: normal Component: MenusPlugin
Severity: normal Keywords: href
Cc: Trac Release: 0.12

Description (last modified by rjollos)

Hi,

If an absolute href is broken trac is installed at root of the domain.

For exemple, if you install your trac at http://trac.myproject.org/ and configure

[mainnav]
wiki.href = /wiki/Home

then TracMenus generates href 'wiki/Home'. This broke the link. (wiki is a netloc).

The offending code is : http://trac-hacks.org/browser/menusplugin/0.11/tracmenus/web_ui.py#L139

menu[name]['label']=menu[name].setdefault('label', html.a())(href=value.startswith('/') and req.href()+value or value)

reg.href() returns '/'. You should trim beginning '' in the resulting href.

Regards,
Étienne

Attachments (0)

Change History (7)

comment:1 Changed 3 years ago by rjollos

  • Description modified (diff)
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #8877, but thanks for the hint at a solution.

comment:2 Changed 3 years ago by rjollos

(In [11038]) Fixes #7399, Refs #7680, #8877, #8953: (0.1.1) Links were invalid when Trac was accessed from the top-most path.

comment:3 Changed 3 years ago by rjollos

(In [11039]) Fixes #7399, Refs #7680, #8877, #8953: (0.1.1) [11038] was the wrong solution. This fix should work better.

comment:4 Changed 3 years ago by rjollos

(In [11154]) Fixes #7399, Refs #7680, #8877, #8953: Allow Href to take care of path joining. Tested in 0.11 and 0.13dev-r10909.

comment:5 Changed 3 years ago by rjollos

(In [11155]) Fixes #7399, Refs #7680, #8877, #8953: Removed egg and pydev files accidentally committed in [11154].

comment:6 Changed 3 years ago by rjollos

(In [11156]) Fixes #7399, Refs #7680, #8877, #8953: Removed egg and pydev files accidentally committed in [11154].

comment:7 Changed 3 years ago by rjollos

(In [11166]) Fixes #7399, Refs #7680, #8877, #8953: Yet another attempt to fix invalid links when req.href = '/'. If the href for a menu item specifies a relative path, the trailing forward slashes are stripped from req.href() so that the two cases are handled: 1) req.href() is '/' and 2) req.href() is '/somepath'.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from cbalan. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.