#7680 closed defect (duplicate)
[PATCH] Invalid links when trac is on accessed from top-most path
Reported by: | HumanInternals | Owned by: | Catalin BALAN |
---|---|---|---|
Priority: | normal | Component: | MenusPlugin |
Severity: | normal | Keywords: | patch |
Cc: | Trac Release: | 0.12 |
Description
The links in that ticket were considered as being spam, so I added \notspam\
to prevent that from happening. Ignore it.
My Trac installation is accessed via http://trac.kelso/. When I add a menu, like that:
query = enabled query.href = /query query.label = Custom Query query.order = 1 query.parent = tickets
It's being rendered as <a \notspam\ href="//query">Custom Query</a>
. The //
at the beginning of the href causes Chrome and Firefox (and possibly others) to think its a link to "http://query/".
When I remove the /
prefix from the href in the configuration, the link becomes <a \notspam\ href="query">Custom Query</a>
, which doesn't work when I'm on a URL like 'http://trac.kelso/ticket/123', as the link is pointing to 'http:trac.kelso/ticket/query'.
It works fine when Trac is installed under a sub directory, such as http://trac.kelso/humaninternals/
, as the link is rendered as <a \notspam\ href="/humaninternals/query">Custom Query</a>
. The issue is when its rendered with two slashes at the beginning.
Attachments (2)
Change History (14)
Changed 14 years ago by
Attachment: | menusplugin-path.patch added |
---|
comment:1 Changed 14 years ago by
Keywords: | patch added |
---|---|
Summary: | Invalid links when trac is on accessed from top-most path → [PATCH] Invalid links when trac is on accessed from top-most path |
comment:2 follow-up: 6 Changed 14 years ago by
The last patch doesn't work properly, as the href is encoded (so characters like '?' won't work). It's not possible to pass as an argument to req.href()
, so I'm uploading a new patch right-strips the base href from '/' characters (href=value.startswith('/') and req.href().rstrip('/')+value or value
)
Changed 14 years ago by
Attachment: | menusplugin-path-2.patch added |
---|
a working patch, as described in comment:2 (was written by me, but I forgot to login)
comment:4 Changed 13 years ago by
comment:5 Changed 13 years ago by
comment:6 follow-up: 10 Changed 13 years ago by
Replying to anonymous:
The last patch doesn't work properly, as the href is encoded (so characters like '?' won't work). It's not possible to pass as an argument to
req.href()
,
I tried some examples using the patch described in comment:10:ticket:7399, and it seems to work fine to pass the value to req.href
.
Here is one of the examples I tried:
/timeline?from=01%2F17%2F2012&daysback=30&changeset=on&milestone=on&wiki=on&update=Update
comment:7 Changed 13 years ago by
comment:8 Changed 13 years ago by
comment:9 Changed 13 years ago by
comment:10 Changed 13 years ago by
Replying to rjollos:
I tried some examples using the patch described in comment:10:ticket:7399, and it seems to work fine to pass the value to
req.href
.Here is one of the examples I tried:
/timeline?from=01%2F17%2F2012&daysback=30&changeset=on&milestone=on&wiki=on&update=Update
My statement here is incorrect. This does not work. I'll be trying to resolve it over in #7399.
comment:11 Changed 13 years ago by
(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'
.
comment:12 Changed 13 years ago by
I'm working a similar issue in #9788 for the BookmarkPlugin, and considering that href = req.path_info + value
might be equivalent to and cleaner than the code fragment (req.href().rstrip('/') + value)
.
Attaching a fix that worked for me - using
req.href()
with an argument, instead of concating it with the href.