From ed0c6534da711198ce48450dfef9186d27772622 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 7 Apr 2025 15:10:58 -0300 Subject: [PATCH] nip27: fix for contents that end in broken strings. --- nip27/blocks.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nip27/blocks.go b/nip27/blocks.go index 1403922..7b1ce9d 100644 --- a/nip27/blocks.go +++ b/nip27/blocks.go @@ -78,7 +78,7 @@ func Parse(content string) iter.Seq[Block] { index = end prevIndex = index continue - case (u >= 5 && content[u-5:u] == "https") || (u >= 4 && content[u-4:u] == "http"): + case ((u >= 5 && content[u-5:u] == "https") || (u >= 4 && content[u-4:u] == "http")) && u+4 < max: m := noURLCharacter.FindStringIndex(content[u+4:]) end := max if m != nil { @@ -108,7 +108,7 @@ func Parse(content string) iter.Seq[Block] { index = end prevIndex = index continue - case (u >= 3 && content[u-3:u] == "wss") || (u >= 2 && content[u-2:u] == "ws"): + case ((u >= 3 && content[u-3:u] == "wss") || (u >= 2 && content[u-2:u] == "ws")) && u+4 < max: m := noURLCharacter.FindStringIndex(content[u+4:]) end := max if m != nil {