From d655b46db5028c35c3f68a95aaace6818553feb7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 26 Feb 2024 13:14:02 +0000 Subject: [PATCH] fix: fix NRE on null HtmlNodeCollection --- OliverBooth/Services/MastodonService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OliverBooth/Services/MastodonService.cs b/OliverBooth/Services/MastodonService.cs index fdc7486..121a6cc 100644 --- a/OliverBooth/Services/MastodonService.cs +++ b/OliverBooth/Services/MastodonService.cs @@ -37,8 +37,14 @@ internal sealed class MastodonService : IMastodonService var document = new HtmlDocument(); document.LoadHtml(status.Content); - HtmlNodeCollection links = document.DocumentNode.SelectNodes("//a"); - foreach (HtmlNode link in links) link.InnerHtml = link.InnerText; + HtmlNodeCollection? links = document.DocumentNode.SelectNodes("//a"); + if (links is not null) + { + foreach (HtmlNode link in links) + { + link.InnerHtml = link.InnerText; + } + } status.Content = document.DocumentNode.OuterHtml; return status;