From 657000ddd6150ae94b424be49dbf7beb5506f1c3 Mon Sep 17 00:00:00 2001 From: Carl Tibule Date: Tue, 21 Feb 2023 23:04:52 -0600 Subject: [PATCH] Escaped HTML special characters and truncated descriptions to 100 GH-13 --- YABA.API/Settings/AutoMapperProfile.cs | 5 ++++- yaba-web/src/components/bookmarks/bookmark.jsx | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/YABA.API/Settings/AutoMapperProfile.cs b/YABA.API/Settings/AutoMapperProfile.cs index a721a3f..920b80a 100644 --- a/YABA.API/Settings/AutoMapperProfile.cs +++ b/YABA.API/Settings/AutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using System.Net; using YABA.API.ViewModels; using YABA.API.ViewModels.Bookmarks; using YABA.API.ViewModels.Tags; @@ -13,7 +14,9 @@ namespace YABA.API.Settings public AutoMapperProfile() { CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Title, opt => opt.MapFrom(src => WebUtility.HtmlDecode(src.Title))) + .ForMember(dest => dest.Description, opt => opt.MapFrom(src => WebUtility.HtmlDecode(src.Description))); CreateMap(); CreateMap(); CreateMap(); diff --git a/yaba-web/src/components/bookmarks/bookmark.jsx b/yaba-web/src/components/bookmarks/bookmark.jsx index 09ef9a0..cc3c09d 100644 --- a/yaba-web/src/components/bookmarks/bookmark.jsx +++ b/yaba-web/src/components/bookmarks/bookmark.jsx @@ -15,7 +15,7 @@ export function Bookmark(props) { {props.bookmark.title} -
{props.bookmark.description.substring(0, 100)}
+
{`${props.bookmark.description.substring(0, 97)}${props.bookmark.description.length >= 97 ? "..." : ""}`}
{ props.bookmark.tags.map((tag) => )