fix #3235 - </script> not being removed from Head Content

This commit is contained in:
sbwalker 2023-09-08 11:09:07 -04:00
parent 037f1ec887
commit 26921c899e
2 changed files with 6 additions and 6 deletions

View File

@ -72,7 +72,7 @@
while (index >= 0) while (index >= 0)
{ {
var element = content.Substring(index, content.IndexOf(">", index) - index + 1); var element = content.Substring(index, content.IndexOf(">", index) - index + 1);
if (!string.IsNullOrEmpty(element) && !element.ToLower().StartsWith("<script")) if (!string.IsNullOrEmpty(element) && !element.ToLower().StartsWith("<script") && !element.ToLower().StartsWith("</script"))
{ {
if (!headcontent.Contains(element)) if (!headcontent.Contains(element))
{ {

View File

@ -437,17 +437,17 @@ namespace Oqtane.Pages
"</script>"; "</script>";
} }
private string ParseScripts(string headcontent) private string ParseScripts(string content)
{ {
// iterate scripts // iterate scripts
var scripts = ""; var scripts = "";
if (!string.IsNullOrEmpty(headcontent)) if (!string.IsNullOrEmpty(content))
{ {
var index = headcontent.IndexOf("<script"); var index = content.IndexOf("<script");
while (index >= 0) while (index >= 0)
{ {
scripts += headcontent.Substring(index, headcontent.IndexOf("</script>", index) + 9 - index); scripts += content.Substring(index, content.IndexOf("</script>", index) + 9 - index);
index = headcontent.IndexOf("<script", index + 1); index = content.IndexOf("<script", index + 1);
} }
} }
return scripts; return scripts;