fix: post title sanitization in inbox (#561)

This commit is contained in:
sevonj authored and GitHub committed 2025-06-10 07:22:53 -07:00
1 parent a40142f9af
commit 84703b8aa2
2 files changed
+15 -2

No files matched your search

+9
View File
@@ -177,3 +177,12 @@ export function canParseUrl(url: string): boolean {
export function instanceId(actorId: string) {
return new URL(actorId).hostname
}
export function escapeHtml(input: string): string {
return input
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
}
+6 -2
View File
@@ -10,6 +10,7 @@
import { t } from '$lib/i18n/translations'
import { getClient } from '$lib/lemmy.svelte.js'
import type { InboxItem } from '$lib/lemmy/inbox.js'
import { escapeHtml } from '$lib/util.svelte'
import { Button } from 'mono-svelte'
import { Eye, EyeSlash, Icon } from 'svelte-hero-icons'
@@ -73,16 +74,19 @@
<div class="flex flex-col">
<div class="text-sm font-normal">
{#if item.type == 'comment_reply'}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html $t('routes.inbox.item.reply', {
user: `<span class="font-medium">${item.creator.name}</span>`,
post: `<span class="font-medium">${item.item.post.name}</span>`,
post: `<span class="font-medium">${escapeHtml(item.item.post.name)}</span>`,
})}
{:else if item.type == 'person_mention'}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html $t('routes.inbox.item.mention', {
user: `<span class="font-medium">${item.creator.name}</span>`,
post: `<span class="font-medium">${item.item.post.name}</span>`,
post: `<span class="font-medium">${escapeHtml(item.item.post.name)}</span>`,
})}
{:else if item.type == 'private_message'}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html $t('routes.inbox.item.message', {
user: `<span class="font-medium">${item.item.creator.name}</span>`,
recipient: `<span class="font-medium">${item.item.recipient.name}</span>`,