Skip to content

Commit a79e416

Browse files
committed
[markdown] Check footnote label and empty map before scanning footnote keys
1 parent 0f00803 commit a79e416

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎pkgs/markdown/lib/src/inline_syntaxes/footnote_ref_syntax.dart‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ class FootnoteRefSyntax {
3131
}) {
3232
secondary ??= false;
3333
final parser = context.parser;
34-
final key = _footnoteLabel(text);
3534
final refs = parser.document.footnoteReferences;
35+
if (refs.isEmpty) {
36+
return null;
37+
}
38+
final key = _footnoteLabel(text);
39+
if (key == null) {
40+
return null;
41+
}
3642
// `label` is what footnoteReferences stored, it is case sensitive.
3743
final label = refs.keys.firstWhere(
3844
(k) => k.toLowerCase() == key,
@@ -41,7 +47,7 @@ class FootnoteRefSyntax {
4147
// `count != null` means footnote was valid.
4248
var count = refs[label];
4349
// And then check if footnote was matched.
44-
if (key == null || count == null) {
50+
if (count == null) {
4551
return null;
4652
}
4753
final result = <Node>[];

0 commit comments

Comments
 (0)