You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/07/12 13:23:29 UTC
[lucene-jira-archive] 01/01: fix stack overflow when parsing lists
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch fix-stackoverflow-in-list-parser
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git
commit a0cc0f5caa0541cd992af480fee8ad2a2978c76f
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Tue Jul 12 22:23:16 2022 +0900
fix stack overflow when parsing lists
---
migration/src/markup/lists.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/migration/src/markup/lists.py b/migration/src/markup/lists.py
index 47853a2c..3ce03ca9 100644
--- a/migration/src/markup/lists.py
+++ b/migration/src/markup/lists.py
@@ -40,6 +40,11 @@ class TweakedList(AbstractMarkup):
for line in tokens:
# print(repr(line))
+ if line == "\n":
+ # can't really explain but if this is the first item, an empty string should be added to preserve line feed
+ if len(result) == 0:
+ result.append("")
+ continue
bullets, text = line.split(" ", maxsplit=1)
nested_indent = 0
@@ -66,12 +71,11 @@ class TweakedList(AbstractMarkup):
NL = LineEnd()
LIST_BREAK = NL + Optional(White(" \t")) + NL | StringEnd()
IGNORE = BlockQuote(**self.init_kwargs).expr | Panel(**self.init_kwargs).expr | Color(**self.init_kwargs).expr
- ROW = Optional(LineStart()) + Combine(
- Optional(White(" \t"))
+ ROW = (LineStart() ^ LineEnd()) + Combine(
+ Optional(NL)
+ Optional(self.nested_token, default="")
+ ListIndent(self.indent_state, self.tokens)
+ SkipTo(NL + Optional(White(" \t")) + Char(self.nested_token + self.tokens) | LIST_BREAK, ignore=IGNORE)
- + Optional(NL),
)
return OneOrMore(ROW, stopOn=LIST_BREAK).setParseAction(self.action)