Merge pull request #4435 from sbwalker/dev
allow <style> tags to be injected using HeadContent
This commit is contained in:
commit
8ac1217165
@ -66,21 +66,17 @@
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(content))
|
if (!string.IsNullOrEmpty(content))
|
||||||
{
|
{
|
||||||
// format head content, remove scripts, and filter duplicate elements
|
if (PageState.RenderMode == RenderModes.Interactive)
|
||||||
content = content.Replace("\n", "");
|
|
||||||
var index = content.IndexOf("<");
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
{
|
||||||
var element = content.Substring(index, content.IndexOf(">", index) - index + 1);
|
// remove scripts
|
||||||
if (!string.IsNullOrEmpty(element) && (PageState.RenderMode == RenderModes.Static || (!element.ToLower().StartsWith("<script") && !element.ToLower().StartsWith("</script"))))
|
var index = content.IndexOf("<script");
|
||||||
|
while (index >= 0)
|
||||||
{
|
{
|
||||||
if (!headcontent.Contains(element))
|
content = content.Remove(index, content.IndexOf("</script>") + 9 - index);
|
||||||
{
|
index = content.IndexOf("<script");
|
||||||
headcontent += element + "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
index = content.IndexOf("<", index + 1);
|
|
||||||
}
|
}
|
||||||
|
headcontent += content + "\n";
|
||||||
}
|
}
|
||||||
return headcontent;
|
return headcontent;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user