#690033 trac: Cannot render old ticket

Package:
trac
Source:
trac
Submitter:
Tommi Vainikainen
Date:
2021-01-11 01:15:12 UTC
Severity:
normal
Tags:
#690033#5
Date:
2012-10-09 08:59:58 UTC
From:
To:
trac from backports has incompatibility with genshi version that causes
error when trying to browse some old tickets.

Call to genshi.core's escape method with two arguments (second being
False) all fail, such as here:

    return resolver(self, ns, target, escape(label, False),
TypeError: unicode() argument 2 must be string, not bool

By modifying call to use keyword argument for second parameter, it
works. Patch below.

Full backtrace:

2012-10-09 11:30:34,656 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.6/dist-packages/trac/web/main.py", line 258, in dispatch
    content_type)
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 868, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 339, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib/pymodules/python2.6/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.6/dist-packages/trac/web/chrome.py", line 970, in _generate
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 327, in _match
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/pymodules/python2.6/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/pymodules/python2.6/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 565, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "/usr/lib/pymodules/python2.6/genshi/template/base.py", line 277, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/lib/pymodules/python2.6/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/lib/python2.6/dist-packages/trac/ticket/templates/ticket_change.html", line 61, in <Expression u'wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)'>
    <py:otherwise>${wiki_to_html(context, change.comment, escape_newlines=preserve_newlines)}</py:otherwise>
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1499, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1454, in generate
    escape_newlines)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1242, in format
    result = re.sub(self.wikiparser.rules, self.replace, line)
  File "/usr/lib/python2.6/re.py", line 151, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1160, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 1156, in handle_match
    return internal_handler(match, fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 708, in _macrolink_formatter
    return self._lhref_formatter(match, fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 540, in _lhref_formatter
    return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 581, in _make_lhref_link
    fullmatch)
  File "/usr/lib/python2.6/dist-packages/trac/wiki/formatter.py", line 589, in _make_link
    return resolver(self, ns, target, escape(label, False),
TypeError: unicode() argument 2 must be string, not bool



Following patch fixes this at least on our backports environment:
--- formatter.py~	2011-02-01 00:05:49.000000000 +0200
+++ formatter.py	2012-10-09 11:33:01.000000000 +0300
@@ -586,10 +586,10 @@
         if ns in self.wikiparser.link_resolvers:
             resolver = self.wikiparser.link_resolvers[ns]
             if arity(resolver) == 5:
-                return resolver(self, ns, target, escape(label, False),
+                return resolver(self, ns, target, escape(label, quotes=False),
                                 fullmatch)
             else:
-                return resolver(self, ns, target, escape(label, False))
+                return resolver(self, ns, target, escape(label, quotes=False))
         elif ns == "mailto":
             from trac.web.chrome import Chrome
             chrome = Chrome(self.env)
@@ -1285,11 +1285,11 @@
     def _indent_formatter(self, match, fullmatch):
         return match
     def _citation_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _heading_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _definition_formatter(self, match, fullmatch):
-        return escape(match, False)
+        return escape(match, quotes=False)
     def _table_cell_formatter(self, match, fullmatch):
         return match
     def _table_row_sep_formatter(self, match, fullmatch):

#690033#10
Date:
2013-02-21 19:38:10 UTC
From:
To:
In one of our servers the reported bug shows up when a wiki page
contained in a old project, just migrated into the server, is displayed.
The bug does not shows up with all wiki pages, though.

The patch published by Vainikainen have solved the problem in our case,
the system information of the server follows the present message.
Thanks for sharing and all the good work.

Best Regards

#690033#15
Date:
2020-01-09 06:08:43 UTC
From:
To:
Dear submitter,

as the package trac has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/948052

The version of this package that was in Debian prior to this removal
can still be found using http://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Scott Kitterman (the ftpmaster behind the curtain)