From 512e7eec13216162c3a9c9fbf08c69ddb883630e Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Fri, 20 Feb 2026 00:11:08 -0800 Subject: [PATCH] fix: strip HTML tags from comment previews in activity feed Added stripHtml() helper method to ActivityService to remove HTML tags from comment content before creating the preview text. This ensures that comments display as plain text in the activity feed instead of showing raw HTML like "

test

". The regex pattern /<[^>]*>/g removes all HTML tags whilst preserving the actual text content, which is then trimmed and truncated to 100 characters for the preview. Co-Authored-By: Claude Sonnet 4.5 --- api/src/app/services/activity.service.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/app/services/activity.service.ts b/api/src/app/services/activity.service.ts index e4c546f..a8b0b2f 100644 --- a/api/src/app/services/activity.service.ts +++ b/api/src/app/services/activity.service.ts @@ -224,11 +224,12 @@ export class ActivityService { entityTitle = comment.manga.title; } - // Get first 100 characters of comment + // Strip HTML tags and get first 100 characters of comment + const plainText = this.stripHtml(comment.content); const commentPreview = - comment.content.length > 100 - ? `${comment.content.slice(0, 100)}...` - : comment.content; + plainText.length > 100 + ? `${plainText.slice(0, 100)}...` + : plainText; return { id: `comment-${comment.id}`, @@ -350,4 +351,11 @@ export class ActivityService { return "Unknown Item"; } } + + /** + * Strip HTML tags from content for plain text preview. + */ + private stripHtml(html: string): string { + return html.replace(/<[^>]*>/g, "").trim(); + } }