Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Ganss.Xss;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -27,6 +28,7 @@ public class NewsItemApiController : Controller
private readonly INewsItemService _newsItemService;
private readonly IMediaService _mediaService;
private readonly IWorkContext _workContext;
private readonly HtmlSanitizer _htmlSanitizer = new();

public NewsItemApiController(IRepository<NewsItem> newsItemRepository, INewsItemService newsItemService, IMediaService mediaService, IWorkContext workContext)
{
Expand Down Expand Up @@ -127,8 +129,8 @@ public async Task<IActionResult> Post(NewsItemForm model)
MetaTitle = model.MetaTitle,
MetaKeywords = model.MetaKeywords,
MetaDescription = model.MetaDescription,
ShortContent = model.ShortContent,
FullContent = model.FullContent,
ShortContent = _htmlSanitizer.Sanitize(model.ShortContent),
FullContent = _htmlSanitizer.Sanitize(model.FullContent),
IsPublished = model.IsPublished,
CreatedBy = currentUser,
LatestUpdatedBy = currentUser
Expand Down Expand Up @@ -172,8 +174,8 @@ public async Task<IActionResult> Put(long id, NewsItemForm model)
newsItem.MetaTitle = model.MetaTitle;
newsItem.MetaKeywords = model.MetaKeywords;
newsItem.MetaDescription = model.MetaDescription;
newsItem.ShortContent = model.ShortContent;
newsItem.FullContent = model.FullContent;
newsItem.ShortContent = _htmlSanitizer.Sanitize(model.ShortContent);
newsItem.FullContent = _htmlSanitizer.Sanitize(model.FullContent);
newsItem.IsPublished = model.IsPublished;
newsItem.LatestUpdatedOn = DateTimeOffset.Now;
newsItem.LatestUpdatedBy = currentUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<EmbeddedResource Include="bundleconfig.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\SimplCommerce.Infrastructure\SimplCommerce.Infrastructure.csproj" />
<ProjectReference Include="..\SimplCommerce.Module.Core\SimplCommerce.Module.Core.csproj" />
Expand Down
Loading