From 33e5d1ff190ef2a0b9b1db052ed4f2756fa3e8e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20R=C3=BCger?=
Date: Sat, 5 Oct 2024 23:56:07 +0200
Subject: [PATCH] blockquote: Fix invalid access
---
renderer/blockquote.go | 5 ++---
testdata/quotes-droph1.html | 4 ++++
testdata/quotes-stripnewlines.html | 3 +++
testdata/quotes.html | 4 ++++
testdata/quotes.md | 5 +++++
5 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/renderer/blockquote.go b/renderer/blockquote.go
index 12100b3..30e8fd0 100644
--- a/renderer/blockquote.go
+++ b/renderer/blockquote.go
@@ -118,13 +118,12 @@ func ParseBlockQuoteType(node ast.Node, source []byte) BlockQuoteType {
// Classifying the next text type node (midNode) will confirm that.
if t == None {
midNode := node.NextSibling()
- rightNode := midNode.NextSibling()
- if midNode.Kind() == ast.KindText {
+ if midNode != nil && midNode.Kind() == ast.KindText {
+ rightNode := midNode.NextSibling()
midTextNode := midNode.(*ast.Text)
if rightNode != nil && rightNode.Kind() == ast.KindText {
rightTextNode := rightNode.(*ast.Text)
-
if string(n.Text(source)) == "[" && string(rightTextNode.Text(source)) == "]" {
t = ghAlertsClassifier.ClassifyingBlockQuote(string(midTextNode.Text(source)))
}
diff --git a/testdata/quotes-droph1.html b/testdata/quotes-droph1.html
index 8b98bc4..4fdba68 100644
--- a/testdata/quotes-droph1.html
+++ b/testdata/quotes-droph1.html
@@ -98,3 +98,7 @@ b
[NOTE]
+
+TL;DR: Thingy!
+More stuff
+
diff --git a/testdata/quotes-stripnewlines.html b/testdata/quotes-stripnewlines.html
index ba9c973..e07a047 100644
--- a/testdata/quotes-stripnewlines.html
+++ b/testdata/quotes-stripnewlines.html
@@ -96,3 +96,6 @@
[NOTE]
+
+TL;DR: Thingy! More stuff
+
diff --git a/testdata/quotes.html b/testdata/quotes.html
index a2d2a00..15a2317 100644
--- a/testdata/quotes.html
+++ b/testdata/quotes.html
@@ -99,3 +99,7 @@ b
[NOTE]
+
+TL;DR: Thingy!
+More stuff
+
diff --git a/testdata/quotes.md b/testdata/quotes.md
index d9de8e0..aeeb7c1 100644
--- a/testdata/quotes.md
+++ b/testdata/quotes.md
@@ -88,3 +88,8 @@
> [Hey !NOTE]
> [NOTE]
+
+
+
+> **TL;DR:** Thingy!
+> More stuff