From 6e0dcddeb8dd5bcc51e92a4dead42c6757e543e1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Jun 2018 15:37:17 -0400 Subject: strip 'noinclude' blocks from release descriptions serverside --- src/SMAPI.Web/Controllers/IndexController.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/SMAPI.Web/Controllers') diff --git a/src/SMAPI.Web/Controllers/IndexController.cs b/src/SMAPI.Web/Controllers/IndexController.cs index a24b470c..f4ade7de 100644 --- a/src/SMAPI.Web/Controllers/IndexController.cs +++ b/src/SMAPI.Web/Controllers/IndexController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using HtmlAgilityPack; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; using StardewModdingAPI.Toolkit; @@ -94,6 +95,19 @@ namespace StardewModdingAPI.Web.Controllers } } + // strip 'noinclude' blocks from release descriptions + foreach (GitRelease release in new[] { stableRelease, betaRelease }) + { + if (release == null) + continue; + + HtmlDocument doc = new HtmlDocument(); + doc.LoadHtml(release.Body); + foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//*[@class='noinclude']")?.ToArray() ?? new HtmlNode[0]) + node.Remove(); + release.Body = doc.DocumentNode.InnerHtml.Trim(); + } + // get versions ReleaseVersion[] stableVersions = this.ParseReleaseVersions(stableRelease).ToArray(); ReleaseVersion[] betaVersions = this.ParseReleaseVersions(betaRelease).ToArray(); -- cgit