From: Günter M. <mi...@us...> - 2023-11-13 18:35:43
|
- **status**: open --> open-fixed - **Comment**: The underlying problem (splitting the "option marker" inside < >) is fixed in [r9473]. This also solves the `IndexError`. Thank you for reporting. --- **[bugs:#474] IndexError while parsing specially crafted option arguments** **Status:** open-fixed **Created:** Tue Sep 12, 2023 07:05 PM UTC by Andrew Pan **Last Updated:** Tue Sep 12, 2023 07:13 PM UTC **Owner:** nobody **Attachments:** - [reproducer.py](https://sourceforge.net/p/docutils/bugs/474/attachment/reproducer.py) (88 Bytes; text/x-python-script) When rendering arbitrary input with the RST parser, I expect docutils to either return successfully or raise a `MarkupError`. However, the following input causes docutils to raise an `IndexError`: `-a<, , >` docutils tries to render this as an option group. It splits the group into individual options: <small>docutils/parsers/rst/states.py:1555:</small> ```python optionstrings = match.group().rstrip().split(', ') ``` Which yields the following array (note the empty string): ``` (Pdb) optionstrings ['-a<', '', ' >'] ``` Which is then tokenized with `split()`. When processing an empty "option", `split()` yields an empty array, causing this statement to raise an `IndexError`: <small>docutils/parsers/rst/states.py:1559:</small> ```python firstopt = tokens[0].split('=', 1) ``` I checked [the documentation](https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#option-lists) and it appears that angle brackets are usually used to denote option arguments. I'm not sure if docutils should parse and render this kind of input. If it shouldn't, it would be nice to get a `MarkupError`. Here's the output from `docutils -V`: `docutils (Docutils 0.20.1, Python 3.11.3, on darwin)` I've reproduced this on macOS `13.5.2 (22G91)` and Ubuntu 22.04 with the attached reproducer. --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |