Skip to content

Commit

Permalink
Refine sanitize config
Browse files Browse the repository at this point in the history
  • Loading branch information
mike182uk committed Jul 31, 2024
1 parent 854a0f8 commit e224c6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import type { PersonData } from './user';
import { ACTOR_DEFAULT_HANDLE } from './constants';

type StoredThing = {
object: object | string;
object: string | {
content: string;
}
}

async function postToArticle(ctx: RequestContext<ContextData>, post: any) {
Expand Down Expand Up @@ -210,7 +212,8 @@ export async function inboxHandler(
thing.object = await db.get([thing.object]) ?? thing.object;
}

if (thing?.object?.content) {
// Sanitize HTML content
if (thing?.object && typeof thing.object !== 'string') {
thing.object.content = sanitizeHtml(thing.object.content, {
allowedTags: ['a', 'p', 'img', 'br', 'strong', 'em', 'span'],
allowedAttributes: {
Expand Down

0 comments on commit e224c6f

Please sign in to comment.