textile/python-textile

Empty description lists throw error

sebix opened this issue · 3 comments

sebix commented

I played a bit with the american fuzzy lop (afl) :)

The examples used for afl are all copied from the examples on the website. It found this issue:

- :=
-

it throws:

Traceback (most recent call last):
  File "/home/ele/tmp/pyfuzz/code3.py", line 8, in <module>
    textile.textile(sys.stdin.read())
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 1415, in textile
    return Textile(html_type=html_type).parse(text)
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 248, in parse
    text = self.block(text)
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 499, in block
    block = Block(self, tag, atts, ext, cite, line)
  File "/usr/lib/python3.6/site-packages/textile/objects/block.py", line 32, in __init__
    self.process()
  File "/usr/lib/python3.6/site-packages/textile/objects/block.py", line 125, in process
    self.content = self.textile.graf(self.content)
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 645, in graf
    text = self.redcloth_list(text)
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 1177, in redcloth_list
    return pattern.sub(self.fRCList, text)
  File "/usr/lib/python3.6/site-packages/textile/core.py", line 1188, in fRCList
    atts, content = m.groups()
AttributeError: 'NoneType' object has no attribute 'groups'
sebix commented

I ran the tests with python3 and using version 2.3.3 (which had more bugs), I need to rerun it with a current version.

This kind of seems like an upstream bug. txstyle only returns:

<dl>
</dl>

If you find more, I'd recommend just posting only the situations where php-textile returns something useful where we fail or don't match. Otherwise, isn't this more like a "garbage in/garbage out" situation?

edit: We should probably fix it so that it doesn't bomb, but it's hard to say what the fix should be given that even php-textile's output isn't particularly helpful.

sebix commented

I think that the function should never fail, even if the input does not make sense. If the input is nonsense, the output can be nonsense too, yes.

php-textile doesn't fail too, it gives an empty list, that's ok.