refactor(starlight): replace external HtmlEncode with local implementation

The Controller.cs file now uses a local HtmlEncode method instead of the external Shared.Models.Templates.UtilsTpl.HtmlEncode utility. This change improves encapsulation and reduces external dependencies while maintaining the same HTML encoding functionality for special characters.
This commit is contained in:
baliasnyifeliks 2026-01-14 09:42:48 +02:00
parent 0d029f362d
commit f32b2b2cc2

View File

@ -193,7 +193,7 @@ namespace StarLight.Controllers
html.Append("'>"); html.Append("'>");
html.Append("<div class=\"videos__item-imgbox videos__movie-imgbox\"></div><div class=\"videos__item-title\">"); html.Append("<div class=\"videos__item-imgbox videos__movie-imgbox\"></div><div class=\"videos__item-title\">");
Shared.Models.Templates.UtilsTpl.HtmlEncode(item.name, html); HtmlEncode(item.name, html);
html.Append("</div></div>"); html.Append("</div></div>");
firstjson = false; firstjson = false;
@ -203,5 +203,24 @@ namespace StarLight.Controllers
return html.ToString(); return html.ToString();
} }
private static void HtmlEncode(string value, StringBuilder sb)
{
if (string.IsNullOrEmpty(value))
return;
foreach (var c in value)
{
switch (c)
{
case '<': sb.Append("&lt;"); break;
case '>': sb.Append("&gt;"); break;
case '&': sb.Append("&amp;"); break;
case '"': sb.Append("&quot;"); break;
case '\'': sb.Append("&#39;"); break;
default: sb.Append(c); break;
}
}
}
} }
} }