Modify ↓
Opened 18 years ago
Closed 18 years ago
#3373 closed defect (fixed)
TracLink 'query:' leads to a Trac IndexError
Reported by: | Owned by: | Matthew Good | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10 |
Component: | wiki system | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
If the following TracLink is inserted in a page :
[query: Query]
this leads to the Python error below. A workaround is :
[query:? Query]
IMO, Trac should take care of adding the ?
in case the query string is empty.
Traceback (most recent call last): File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/web/main.py", line 314, in dispatch_request dispatcher.dispatch(req) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/web/main.py", line 199, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.osf1-V5.1-alpha/egg/tractags/web_ui.py", line 64, in process_request File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/web_ui.py", line 133, in process_request self._render_view(req, db, page) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/web_ui.py", line 445, in _render_view req.hdf['wiki'] = { File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 987, in wiki_to_html Formatter(env, req, absurls, db).format(wikitext, out, escape_newlines) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 813, in format result = re.sub(self.wiki.rules, self.replace, line) File "/usr/local/Python/2.4.1/lib/python2.4/sre.py", line 142, in sub return _compile(pattern, 0).sub(repl, string, count) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 759, in replace replacement = self.handle_match(fullmatch) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 755, in handle_match return internal_handler(match, fullmatch) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 362, in _lhref_formatter return self._make_link(ns, target, match, label) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/wiki/formatter.py", line 369, in _make_link escape(label, False)) File "/www/Web/servers/trac/0.10dev-3507/lib/python2.4/site-packages/trac/ticket/query.py", line 662, in _format_link if query[0] == '?': IndexError: string index out of range
Attachments (0)
Change History (3)
comment:1 by , 18 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 18 years ago
The fix here is trivial, but I'd like to add some unit tests for the query links, so I'll come back to this later today.
comment:3 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Ok, fixed this and added a test case in [3579]
Note:
See TracTickets
for help on using tickets.
Actually the behavior is slightly different when the query link is prefixed with a "?" since it assumes that the query URL parameters are included verbatim. When it's omitted the query is parsed for proper syntax.
However, this is one of the reasons
.startswith()
should be used instead of string indexing.