textile / python-textile

A Python port of Textile, A humane web text generator
Other
69 stars 23 forks source link

Textile raises IndexError on empty string #26

Closed ziima closed 8 years ago

ziima commented 8 years ago

When textile is run with empty string as argument it raises unexpected IndexError

textile.textile('')
.../textile/core.pyc in textile(text, html_type, encoding, output)
   1336 
   1337     """
-> 1338     return Textile(html_type=html_type).parse(text)
   1339 
   1340 

.../textile/core.pyc in parse(self, text, rel, sanitize)
    247                         'pre', 'h[1-6]',
    248                         'fn{0}+'.format(regex_snippets['digit']), '###']
--> 249                 text = self.block(text)
    250                 text = self.placeNoteLists(text)
    251         else:

.../textile/core.pyc in block(self, text)
    451                     line = '{0}\n{1}'.format(out.pop(), line)
    452                 whitespace = ' \t\n\r\f\v'
--> 453                 if ext or not line[0] in whitespace:
    454                     block = Block(self, tag, atts, ext, cite, line)
    455                     if block.tag == 'p' and not has_raw_text(block.content):

IndexError: string index out of range

I worked in textile 2.2 and 2.1, where it returned empty string.

ikirudennis commented 8 years ago

Fixed in freshly uploaded version 2.3.1