Modify

#14012 closed defect (fixed)

Exception with wiki table

Reported by: Cinc-th Owned by: Cinc-th
Priority: normal Component: TracWikiPrintPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.4

Description

With a wiki page holding a malformed table there is an exception when creating a PDF:

File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/trac/web/main.py", line 639, in dispatch_request          
  dispatcher.dispatch(req)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/trac/web/main.py", line 250, in dispatch          
  resp = chosen_handler.process_request(req)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/trac/wiki/web_ui.py", line 186, in process_request          
  format, versioned_page.name)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/trac/mimeview/api.py", line 1020, in send_converted          
  iterable=iterable)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/trac/mimeview/api.py", line 705, in convert_content          
  conversion.key)
File "/Users/cinc/projects/tracwikiprintplugin/1.4/wikiprint/wikiprint.py", line 463, in convert_content          
  date=format_datetime(to_datetime(None)))
File "/Users/cinc/projects/tracwikiprintplugin/1.4/wikiprint/wikiprint.py", line 301, in html_to_pdf          
  link_callback=loader.getFileName)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/document.py", line 105, in pisaDocument          
  encoding, context=context, xml_output=xml_output)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/document.py", line 67, in pisaStory          
  pisaParser(src, context, default_css, xhtml, encoding, xml_output)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 761, in pisaParser          
  pisaLoop(document, context)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 699, in pisaLoop          
  pisaLoop(node, context, path, **kw)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 643, in pisaLoop          
  pisaLoop(nnode, context, path, **kw)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 643, in pisaLoop          
  pisaLoop(nnode, context, path, **kw)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 648, in pisaLoop          
  obj.end(context)
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/xhtml2pdf/tables.py", line 199, in end          
  style=TableStyle(tdata.styles))
File "/Users/cinc/projects/venvs/Trac-1.4/lib/python2.7/site-packages/reportlab/platypus/tables.py", line 276, in __init__          
  raise ValueError("%s must have at least a row and column" % self.identity())

Example for such a table can be found on WikiFormatting page (last section, Miscellaneous).

This is a minimal test case:

== Broken Table

||= Header 1 =||= Header 2 =||
{{{#!td
  TD 1
}}}
{{{#!td
  TD 2
}}}
|----------------------------------

The last line |---------------------------------- is converted into a table row <tr></tr> without any table cells <td></td> causing the problem.

Attachments (0)

Change History (1)

comment:1 Changed 14 months ago by Cinc-th

Resolution: fixed
Status: assignedclosed

In 18291:

TracWikiPrintPlugin: remove empty<tr></tr> from html before creating pdf. Fixes exception in parsing libs because of missing <td>.

Closes #14012

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Cinc-th.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.