🐛 Fix NPE

This commit is contained in:
Daniel 2025-02-07 16:35:07 +08:00
parent 1ec54282c7
commit 973f99b690
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 12 additions and 0 deletions

View file

@ -483,6 +483,10 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChild
}
paragraphParents := sql.GetBlocks(paragraphParentIDs)
for _, p := range paragraphParents {
if nil == p {
continue
}
if "i" == p.Type || "h" == p.Type {
linkRefs = append(linkRefs, fromSQLBlock(p, keyword, beforeLen))
processedParagraphs.Add(p.ID)
@ -589,6 +593,10 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
originalRefBlockIDs = map[string]string{}
processedParagraphs := hashset.New()
for _, parent := range paragraphParents {
if nil == parent {
continue
}
if "NodeListItem" == parent.Type || "NodeBlockquote" == parent.Type || "NodeSuperBlock" == parent.Type {
refBlock := parentRefParagraphs[parent.ID]
if nil == refBlock {

View file

@ -624,6 +624,10 @@ func buildBacklinkListItemRefs(refDefs []*RefDefs) (originalRefBlockIDs map[stri
luteEngine := util.NewLute()
processedParagraphs := hashset.New()
for _, parent := range paragraphParents {
if nil == parent {
continue
}
if "NodeListItem" == parent.Type || "NodeBlockquote" == parent.Type || "NodeSuperBlock" == parent.Type {
refBlock := parentRefParagraphs[parent.ID]
if nil == refBlock {