Description

When pasting an OpenOffice Spreadsheet into the GUI editor the HTML includes both a <title> and <style> element. These elements cause moinmoin to die with a raise ConvertError exception. At this point you have lost the edits you have made so far.

Steps to reproduce

  1. open an OpenOffice Spreadsheet

  2. Copy any number of tables
  3. Paste them into the moinmoin GUI editor

  4. Click "Save Changes", "Preview", or "Text Mode"

Example

Component selection

Details

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

    • /var/lib/python-support/python2.5/MoinMoin/request.py in run (self=<MoinMoin.request.RequestCGI object at 0x2b2e0037a950>)

      1. 1171 self.page.send_page(self, msg=msg)
      2. 1172 else:
      3. 1173 handler(self.page.page_name, self)
      4. 1174
      5. 1175 # generate page footer (actions that do not want this footer use
        • handler = <function do_edit at 0xa5cf50>

        • self = <MoinMoin.request.RequestCGI object at 0x2b2e0037a950>

        • self.page = <MoinMoin.Page.Page instance at 0x9dfb00>

        • self.page.page_name = u'IT/blah'
    • /var/lib/python-support/python2.5/MoinMoin/wikiaction.py in do_edit (pagename=u'IT/blah', request=<MoinMoin.request.RequestCGI object at 0x2b2e0037a950>)

      1. 597 try:
      2. 598 if lasteditor == 'gui':
      3. 599 savetext = convert(request, pagename, savetext)
      4. 600
      5. 601 # IMPORTANT: normalize text from the form. This should be done in
        • savetext = u'<meta content="text/html; charset=utf-8" http-eq...6" align="left">c</td> \t\t</tr> \t</tbody> </table>'

        • convert = <function convert at 0xcb4e60>

        • request = <MoinMoin.request.RequestCGI object at 0x2b2e0037a950>

        • pagename = u'IT/blah'
    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in convert (request=<MoinMoin.request.RequestCGI object at 0x2b2e0037a950>, pagename=u'IT/blah', text=u'<page><meta content="text/html; charset=utf-8" h...n="left">c</td> \t\t</tr> \t</tbody> </table></page>')

      1. 1220 tree = parse(request, text)
      2. 1221 strip_whitespace().do(tree)
      3. 1222 text = convert_tree(request, pagename).do(tree)
      4. 1223 text = '\n'.join([s.rstrip() for s in text.splitlines()] + []) # remove trailing blanks

      5. 1224 return text
        • text = u'<page><meta content="text/html; charset=utf-8" h...n="left">c</td> \t\t</tr> \t</tbody> </table></page>'

        • global convert_tree = <class 'MoinMoin.converter.text_html_text_x_moin.convert_tree'>

        • request = <MoinMoin.request.RequestCGI object at 0x2b2e0037a950>

        • pagename = u'IT/blah'
        • ).do undefined
        • tree = <xml.dom.minidom.Document instance at 0xcf2170>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in do (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, tree=<xml.dom.minidom.Document instance at 0xcf2170>)

      1. 462 self.depth = 0
      2. 463 self.text = []
      3. 464 self.visit(tree.documentElement)
      4. 465 self.check_whitespace()
      5. 466 return .join(self.text)

        • self = <MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>

        • self.visit = <bound method convert_tree.visit of <MoinMoin.co...tml_text_x_moin.convert_tree object at 0xcabbd0>>

        • tree = <xml.dom.minidom.Document instance at 0xcf2170>

        • tree.documentElement = <DOM Element: page at 0xd056c8>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in visit (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, node=<DOM Element: page at 0xd056c8>)

      1. 409 nodeType = node.nodeType
      2. 410 if node.nodeType == Node.ELEMENT_NODE:
      3. 411 return self.visit_element(node)
      4. 412 elif node.nodeType == Node.ATTRIBUTE_NODE:
      5. 413 return self.visit_attribute(node)
        • self = <MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>

        • self.visit_element = <bound method convert_tree.visit_element of <Moi...tml_text_x_moin.convert_tree object at 0xcabbd0>>

        • node = <DOM Element: page at 0xd056c8>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in visit_element (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, node=<DOM Element: page at 0xd056c8>)

      1. 511 func = getattr(self, "process_%s" % name, None)
      2. 512 if func:
      3. 513 func(node)
      4. 514 else:
      5. 515 self.process_inline(node)
        • func = <bound method convert_tree.process_page of <Moin...tml_text_x_moin.convert_tree object at 0xcabbd0>>

        • node = <DOM Element: page at 0xd056c8>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in process_page (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, node=<DOM Element: page at 0xd056c8>)

      1. 532 for i in node.childNodes:
      2. 533 if i.nodeType == Node.ELEMENT_NODE:
      3. 534 self.visit_element(i)
      4. 535 elif i.nodeType == Node.TEXT_NODE: # if this is missing, all std text under a headline is dropped!
      5. 536 txt = i.data.strip() # IMPORTANT: don't leave this unstripped or there will be wrong blanks
        • self = <MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>

        • self.visit_element = <bound method convert_tree.visit_element of <Moi...tml_text_x_moin.convert_tree object at 0xcabbd0>>

        • i = <DOM Element: title at 0xd05998>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in visit_element (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, node=<DOM Element: title at 0xd05998>)

      1. 513 func(node)
      2. 514 else:
      3. 515 self.process_inline(node)
      4. 516
      5. 517 def visit_node_list_element_only(self, nodelist):
        • self = <MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>

        • self.process_inline = <bound method convert_tree.process_inline of <Mo...tml_text_x_moin.convert_tree object at 0xcabbd0>>

        • node = <DOM Element: title at 0xd05998>

    • /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py in process_inline (self=<MoinMoin.converter.text_html_text_x_moin.convert_tree object at 0xcabbd0>, node=<DOM Element: title at 0xd05998>)

      1. 767 command = "" # just throw away unsupported elements
      2. 768 else:
      3. 769 raise ConvertError("process_inline: Don't support %s element" % name)

      4. 770
      5. 771 self.text.append(command)

ConvertError

process_inline: Don't support title element

System Details

Workaround

--- /var/tmp/text_html_text_x_moin.py   2008-05-03 18:53:01.000000000 -0400
+++ /var/lib/python-support/python2.5/MoinMoin/converter/text_html_text_x_moin.py       2008-05-03 18:51:46.000000000 -0400
@@ -763,10 +763,12 @@
             command = ",,"
         elif name == 'sup':
             command = "^"
-        elif name in ('font', 'meta', ):
+        elif name in ('font', 'meta', 'title', 'style' ):
             command = "" # just throw away unsupported elements
         else:
-            raise ConvertError("process_inline: Don't support %s element" % name)
+            # Unknown elements will be commented inline.  No crash
+            #raise ConvertError("process_inline: Don't support %s element" % name)
+            command = "\n## Unsupported Element: <"+name+">\n"
         
         self.text.append(command)
         for i in node.childNodes:

Discussion

I seems to me that the best way to deal with an exception here is to output what we can without disrupting the environment. Adding a comment before an unidentified element and allow the user to remove that element or fix any type-o's seems best to me.

My solution here disables completely the title and style elements that are the cause of the crash, but it also changes the default behavior in case there are other unexpected issues.

Hi, there were lot's of changes done in 1.6.x already please try your document here or on http://test17.moinmo.in -- ReimarBauer 2008-05-06 16:58:24

it works fine. maybe you should use paste from ms word button. -- MoonByeongweon 2008-07-29 07:37:21

Some formattings seem to get lost if you do use the paste from ms word button. But that may dependend on the document. The document I tried looks a bit better by pasted directly into the gui editor. -- ReimarBauer 2008-08-07 21:44:26

I implemented your changes to the code (thank you). That allowed me to see what was causing the problem: it was empty cells in a spreadsheet. So, my workaround has been to make sure that, when pasting a spreadsheet, put something on each and every cell. -- DavideAndrea 2008-12-01 21:44:26

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/GuiEditorPasteFromOpenOfficeCausingConvertError (last edited 2008-12-02 16:01:39 by ReimarBauer)