From 452d0af8c918c7e634757a5884b957d9fca0fb5e Mon Sep 17 00:00:00 2001 From: sbwalker Date: Tue, 23 May 2023 11:16:07 -0400 Subject: [PATCH] add null check --- Oqtane.Client/UI/ThemeBuilder.razor | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Oqtane.Client/UI/ThemeBuilder.razor b/Oqtane.Client/UI/ThemeBuilder.razor index c215e3ffe..157a49994 100644 --- a/Oqtane.Client/UI/ThemeBuilder.razor +++ b/Oqtane.Client/UI/ThemeBuilder.razor @@ -66,15 +66,18 @@ private string AddHeadContent(string headcontent, string content) { - // format head content, remove scripts, and filter duplicate elements - var elements = (">" + content.Replace("\n", "") + "<").Split("><"); - foreach (var element in elements) + if (!string.IsNullOrEmpty(content)) { - if (!string.IsNullOrEmpty(element) && !element.Contains("script")) + // format head content, remove scripts, and filter duplicate elements + var elements = (">" + content.Replace("\n", "") + "<").Split("><"); + foreach (var element in elements) { - if (!headcontent.Contains("<" + element + ">")) + if (!string.IsNullOrEmpty(element) && !element.Contains("script")) { - headcontent += "<" + element + ">" + "\n"; + if (!headcontent.Contains("<" + element + ">")) + { + headcontent += "<" + element + ">" + "\n"; + } } } }