Skip to content

Commit

Permalink
fix: no "assertion failed" caused by backslash line break in link label
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Jan 17, 2021
1 parent d4e59ac commit 341e85f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions corpus/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ ss_*.
(soft_line_break)
(text)))

================================================================================
#14 - Assertion failed caused by backslash line break followed by backslash escape in link label
================================================================================
[
#k
V\
*)\\
]:[[z
[<!&<&s!j&P

--------------------------------------------------------------------------------

(document
(link_reference_definition
(link_label
(text)
(backslash_escape)
(text))
(link_destination
(text)))
(paragraph
(text)))

================================================================================
#14 - SIGSEGV caused by incorrect end condition for the unpaired link title
================================================================================
Expand All @@ -53,3 +76,4 @@ ss_*.
(document
(paragraph
(text)))

6 changes: 5 additions & 1 deletion src/tree_sitter_markdown/inline_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,10 @@ void hdl_paired_lnk_ref_def(Lexer &lxr, InlineDelimiterList &inl_dlms, InlineCon
inl_ctx_stk.pop_paired(lnk_end_itr);
assert(inl_ctx_stk.empty());
for (InlineDelimiterList::Iterator itr = ++lnk_bgn_itr; itr != lnk_end_itr;) {
if (itr->sym() == SYM_BSL_ESC) itr++;
if (itr->sym() == SYM_BSL_ESC || itr->sym() == SYM_BSL_LBK) {
if (itr->sym() == SYM_BSL_LBK) itr->set_yes(false);
itr++;
}
else itr = inl_dlms.erase(itr);
}
}
Expand Down Expand Up @@ -1806,6 +1809,7 @@ void hdl_unpaired_inl_dlm(Lexer &lxr, InlineDelimiterList &inl_dlms, InlineConte
);
if (
lnk_ref_def_end_mkr_nxt_itr != blk_dlms.end()
&& lnk_ref_def_end_mkr_nxt_itr->sym() == SYM_PGH_END_MKR
) blk_dlms.erase(lnk_ref_def_end_mkr_nxt_itr, blk_dlms.end());
return;
}
Expand Down

0 comments on commit 341e85f

Please sign in to comment.