Edgewall Software

Opened 5 years ago

Closed 5 years ago

#13045 closed defect (fixed)

ParseError: mismatched tag: line NNN, column CC - in VIEW TICKETS action

Reported by: trac@… Owned by: Jun Omae
Priority: high Milestone: 1.0.17
Component: wiki system Version: 1.3.2
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Wrap macro's content with </p>...<p> only when it is in a paragraph.

API Changes:
Internal Changes:

Description (last modified by anonymous)

How to Reproduce

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

I've created a Custom query and entered following text into the query Description field:

- 6.3.2a [[TicketQuery(milestone=6.3.2a, progress)]]  

The TicketQuery macro works in the preview mode but the list of Available Reports or View Tickets action crashes.

Request parameters:


User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

System Information

Trac 1.3.2
Babel 2.6.0
Genshi 0.7 (without speedups)
Jinja2 2.10
pysqlite 2.6.0
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]
pytz 2018.4
setuptools 39.2.0
SQLite 3.14.2
jQuery 1.12.4
jQuery UI 1.12.1
jQuery Timepicker 1.6.3

Enabled Plugins

timingandestimationplugin 1.5.9
traccustomfieldadmin 0.2.13
tracmastertickets 4.0.2
tracsubticketsplugin 0.5.3

Interface Customization

site-htdocs malotraccloud3.jpg

Python Traceback

Traceback (most recent call last):
  File "e:\pythonvirtual\trac13\lib\site-packages\trac\web\main.py", line 640, in _dispatch_request
  File "e:\pythonvirtual\trac13\lib\site-packages\trac\web\main.py", line 263, in dispatch
  File "e:\pythonvirtual\trac13\lib\site-packages\trac\web\chrome.py", line 1418, in render_template
    fragment, iterable, method)
  File "e:\pythonvirtual\trac13\lib\site-packages\trac\web\chrome.py", line 1480, in _render_jinja_template
  File "e:\pythonvirtual\trac13\lib\site-packages\trac\web\chrome.py", line 1911, in _filter_jinja_page
    stream = XML(content)
  File "build\bdist.win-amd64\egg\genshi\input.py", line 275, in XML
    return Stream(list(XMLParser(StringIO(text))))
  File "build\bdist.win-amd64\egg\genshi\core.py", line 289, in _ensure
    for event in stream:
  File "build\bdist.win-amd64\egg\genshi\input.py", line 449, in _coalesce
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "build\bdist.win-amd64\egg\genshi\input.py", line 169, in _generate
    raise ParseError(msg, self.filename, e.lineno, e.offset)
ParseError: mismatched tag: line 2135, column 54

Attachments (0)

Change History (6)

comment:1 by anonymous, 5 years ago

Description: modified (diff)

comment:2 by Jun Omae, 5 years ago

Component: renderingwiki system

Malformed html is rendered from a list with TicketQuery(progress) macro in wiki text. As the result, the ParseError is raised if plugins which implements ITemplateStreamFilter components are enabled.

<ul><li>list </p><div class="trac-progress">
             ^^^^ missing <p>

Trac 1.0/1.2 has the same issue but the ParseError is not raised. Wiki text renders a Markup instance and Genshi doesn't parse the Markup instance as XML.

Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import trac
>>> from trac import __version__
>>> __version__
>>> from trac.test import EnvironmentStub
>>> from trac.loader import load_components
>>> from trac.wiki.formatter import format_to_html
>>> from trac.test import MockRequest
>>> from trac.web.chrome import web_context
>>> env = EnvironmentStub()
>>> load_components(env)
>>> req = MockRequest(env)
>>> context = web_context(req)
>>> print(format_to_html(env, context, ' - list [[TicketQuery(id=0,format=progress)]]\n'))
<ul><li>list </p><div class="trac-progress">
  <table class="progress">
      <td class="closed" style="display: none">
        <a href="/trac.cgi/query?status=closed&amp;id=0&amp;group=resolution&amp;max=0&amp;order=id" title="0/0 closed"></a>
      <td class="open" style="display: none">
        <a href="/trac.cgi/query?status=assigned&amp;status=new&amp;status=accepted&amp;status=reopened&amp;id=0&amp;max=0&amp;order=id" title="0/0 active"></a>

  <p class="percent">0%</p>

  <p class="legend">
    <span class="first interval">
      <a href="/trac.cgi/query?id=0&amp;max=0&amp;order=id">Total number of tickets: 0</a>
    <span class="interval">
      - <a href="/trac.cgi/query?status=closed&amp;id=0&amp;group=resolution&amp;max=0&amp;order=id">closed: 0</a>
    <span class="interval">
      - <a href="/trac.cgi/query?status=assigned&amp;status=new&amp;status=accepted&amp;status=reopened&amp;id=0&amp;max=0&amp;order=id">active: 0</a>

comment:3 by Jun Omae, 5 years ago

That behavior is introduced in [10905] at source:/tags/trac-1.3.2/trac/wiki/formatter.py@:411#L384. Ideally, we should close and open with the container element.

Version 0, edited 5 years ago by Jun Omae (next)

comment:4 by Jun Omae, 5 years ago

Milestone: next-dev-1.3.x1.0.17
Owner: set to Jun Omae
Status: newassigned

Proposed changes in jomae.git@t13045.

Last edited 5 years ago by Jun Omae (previous) (diff)

comment:5 by Ryan J Ollos, 5 years ago

The fix looks good to me.

comment:6 by Jun Omae, 5 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks for the reviewing. Committed in [16687] and merged in [16688-16689].

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.