Edgewall Software

Ticket #3373 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

TracLink 'query:' leads to a Trac IndexError

Reported by: jouvin@… Owned by: mgood
Priority: normal Milestone: 0.10
Component: wiki system Version: devel
Severity: normal Keywords:
Cc:

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

Change History

Changed 2 years ago by mgood

  • owner changed from jonas to mgood
  • status changed from new to assigned

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.

Changed 2 years ago by mgood

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.

Changed 2 years ago by mgood

  • status changed from assigned to closed
  • resolution set to fixed

Ok, fixed this and added a test case in [3579]

Add/Change #3373 (TracLink 'query:' leads to a Trac IndexError)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from mgood. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.