diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-10-04 22:06:41 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-11-05 16:39:13 +0200 |
commit | 524ab7b5357e66b935a42956ec365a511e62e5ed (patch) | |
tree | 925ccdb506ca5a1ff80533ade56c0aec44927a07 /tests/shared | |
parent | 77455a9a8c678daf4a3035ce0c835f7bfeb617ee (diff) |
Avoid crashing when the end of an empty markdown list is detected
The markdown parser generates empty lists in some cases when a character
that can be used as a bullet is found on a line by itself.
cbEnterBlock() and cbLeaveBlock() are called symmetrically in such cases.
QStack::pop() on an empty stack triggers an assert, so push and pop need
to be done symmetrically too. But it's difficult to actually create the
list as soon as the MD_BLOCK_UL or MD_BLOCK_OL callback occurs, without
breaking the case fixed in 7224d0e427d71e559b928c44634839b4791c1416 (and
probably other cases). That's because QTextCursor::insertList() creates
a list item at the same time as it creates the list itself, and also
inherits block formatting from the previous block. We now insert empty
lists with empty items whenever the need for that is detected though,
and there's a failsafe to prevent popping in case something still goes
wrong with that logic. We aren't strict about reproducing the original
markdown when regenerating it via toMarkdown(), but it's getting closer.
Fixes: QTBUG-78870
Change-Id: Ided194ce7aec2710c60dbac42761ee4169ed9b78
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Diffstat (limited to 'tests/shared')
0 files changed, 0 insertions, 0 deletions