fix: post title sanitization in inbox (#561)
This commit is contained in:
1 parent
a40142f9af
commit
84703b8aa2
2 files changed
+15
-2
No files matched your search
@@ -177,3 +177,12 @@ export function canParseUrl(url: string): boolean {
|
|||||||
export function instanceId(actorId: string) {
|
export function instanceId(actorId: string) {
|
||||||
return new URL(actorId).hostname
|
return new URL(actorId).hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function escapeHtml(input: string): string {
|
||||||
|
return input
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''')
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import type { InboxItem } from '$lib/lemmy/inbox.js'
|
import type { InboxItem } from '$lib/lemmy/inbox.js'
|
||||||
|
import { escapeHtml } from '$lib/util.svelte'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { Eye, EyeSlash, Icon } from 'svelte-hero-icons'
|
import { Eye, EyeSlash, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
@@ -73,16 +74,19 @@
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="text-sm font-normal">
|
<div class="text-sm font-normal">
|
||||||
{#if item.type == 'comment_reply'}
|
{#if item.type == 'comment_reply'}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html $t('routes.inbox.item.reply', {
|
{@html $t('routes.inbox.item.reply', {
|
||||||
user: `<span class="font-medium">${item.creator.name}</span>`,
|
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'}
|
{:else if item.type == 'person_mention'}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html $t('routes.inbox.item.mention', {
|
{@html $t('routes.inbox.item.mention', {
|
||||||
user: `<span class="font-medium">${item.creator.name}</span>`,
|
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'}
|
{:else if item.type == 'private_message'}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
{@html $t('routes.inbox.item.message', {
|
{@html $t('routes.inbox.item.message', {
|
||||||
user: `<span class="font-medium">${item.item.creator.name}</span>`,
|
user: `<span class="font-medium">${item.item.creator.name}</span>`,
|
||||||
recipient: `<span class="font-medium">${item.item.recipient.name}</span>`,
|
recipient: `<span class="font-medium">${item.item.recipient.name}</span>`,
|
||||||
|
|||||||
Reference in new issue
Block a user