Edgewall Software

Opened 11 years ago

Last modified 11 years ago

#11302 closed defect

error with relative link to parent wiki page from an attachment description — at Version 3

Reported by: Christian Boos Owned by: Christian Boos
Priority: normal Milestone: 1.0.2
Component: wiki system Version: 1.0-stable
Severity: normal Keywords:
Cc: Ryan J Ollos Branch:
Release Notes:

Fix a glitch making it impossible to edit a page if a description of an attachment contained some forms of relative link.

API Changes:
Internal Changes:

Description

How to Reproduce

While doing a GET operation on /wiki/WikiStart, Trac issued an internal error.

The link in question had the form [./@1#TheId].

I stumbled upon this error once I started to edit the page. The attachment operation itself and the wiki view was working fine.

Request parameters:

{'action': u'edit', 'page': u'WikiStart'}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.37 Safari/537.36

System Information

System information not available

Enabled Plugins

Plugin information not available

Python Traceback

Traceback (most recent call last):
  File "c:\Trac\repos\1.0-stable\trac\web\main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "c:\Trac\repos\1.0-stable\trac\web\main.py", line 233, in dispatch
    content_type)
  File "c:\Trac\repos\1.0-stable\trac\web\chrome.py", line 1029, in render_template
    encoding='utf-8')
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 58, in encode
    for chunk in iterator:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 350, in __call__
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 829, in __call__
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 669, in __call__
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 774, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\output.py", line 594, in __call__
    for ev in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 288, in _ensure
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 288, in _ensure
    for event in stream:
  File "c:\Trac\repos\1.0-stable\trac\web\chrome.py", line 1167, in _strip_accesskeys
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 288, in _ensure
    for event in stream:
  File "c:\Trac\repos\1.0-stable\trac\web\chrome.py", line 1156, in _generate
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 617, in _include
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\markup.py", line 326, in _match
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 557, in _flatten
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 288, in _ensure
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\path.py", line 588, in _generate
    subevent = next()
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 617, in _include
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\markup.py", line 315, in _strip
    event = next()
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 557, in _flatten
    for kind, data, pos in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\core.py", line 288, in _ensure
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\path.py", line 588, in _generate
    subevent = next()
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 617, in _include
    for event in stream:
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\markup.py", line 315, in _strip
    event = next()
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 577, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\base.py", line 289, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "c:\Dev\Python273\lib\site-packages\genshi-0.6.1-py2.7.egg\genshi\template\eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "c:\Trac\repos\1.0-stable\trac\templates\list_of_attachments.html", line 34, in <Expression u'wiki_to_oneliner(context, attachment.description)'>
    <q py:if="compact and attachment.description">${wiki_to_oneliner(context, attachment.description)}</q>
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 1553, in format_to_oneliner
    return InlineHtmlFormatter(env, context, wikidom).generate(shorten)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 1529, in generate
    shorten)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 1385, in format
    result = re.sub(self.wikiparser.rules, self.replace, result)
  File "c:\Dev\Python273\lib\re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 1201, in replace
    replacement = self.handle_match(fullmatch)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 1197, in handle_match
    return internal_handler(match, fullmatch)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 591, in _lhref_formatter
    return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 621, in _make_lhref_link
    label, fullmatch)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 656, in _make_link
    return self._make_intertrac_link(ns, target, label) or \
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 661, in _make_intertrac_link
    res = self.get_intertrac_url(ns, target)
  File "c:\Trac\repos\1.0-stable\trac\wiki\formatter.py", line 667, in get_intertrac_url
    url = intertrac.get(ns + '.url')
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

This happens because context in the template data was the default (toplevel) context, and that was what was used by the list_of_attachments included template.

Fix and test follows.

Change History (3)

comment:1 by Christian Boos, 11 years ago

Status: newassigned

comment:2 by Remy Blank, 11 years ago

This has probably nothing to do with this bug, but is the trailing / necessary? I.e. isn't the canonical representation of that link [.@1#TheId]?

in reply to:  2 comment:3 by Christian Boos, 11 years ago

Replying to rblank:

… isn't the canonical representation of that link [.@1#TheId]?

That would be another bug… [.@1#TheId] isn't detected as a relative wiki link, whereas [[.@1#TheId]] is.

Note

Note that [.#Note note] (note) and even [.?version=3#Note note at version 3] (note at version 3) work not only for Wiki pages but also for tickets.

Note: See TracTickets for help on using tickets.