Merge pull request #4435 from sbwalker/dev

allow <style> tags to be injected using HeadContent
This commit is contained in:
Shaun Walker 2024-07-18 15:01:43 -04:00 committed by GitHub
commit 8ac1217165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,21 +66,17 @@
{
if (!string.IsNullOrEmpty(content))
{
// format head content, remove scripts, and filter duplicate elements
content = content.Replace("\n", "");
var index = content.IndexOf("<");
while (index >= 0)
if (PageState.RenderMode == RenderModes.Interactive)
{
var element = content.Substring(index, content.IndexOf(">", index) - index + 1);
if (!string.IsNullOrEmpty(element) && (PageState.RenderMode == RenderModes.Static || (!element.ToLower().StartsWith("<script") && !element.ToLower().StartsWith("</script"))))
// remove scripts
var index = content.IndexOf("<script");
while (index >= 0)
{
if (!headcontent.Contains(element))
{
headcontent += element + "\n";
}
content = content.Remove(index, content.IndexOf("</script>") + 9 - index);
index = content.IndexOf("<script");
}
index = content.IndexOf("<", index + 1);
}
headcontent += content + "\n";
}
return headcontent;
}