feat: prevent html parsing when there is not html

This commit is contained in:
Nevo David 2025-08-07 12:55:51 +07:00
parent 5bf30484b6
commit 3cc2ddc47c
3 changed files with 9 additions and 1 deletions

View File

@ -911,7 +911,7 @@ const CalendarItem: FC<{
</div>
<div className="w-full relative">
<div className="absolute top-0 start-0 w-full text-ellipsis break-words line-clamp-1 text-left">
{stripHtmlValidation('none', post.content, false, true) ||
{stripHtmlValidation('none', post.content, false, true, false) ||
'no content'}
</div>
</div>

View File

@ -136,8 +136,14 @@ export const stripHtmlValidation = (
val: string,
replaceBold = false,
none = false,
plain = false,
convertMentionFunction?: (idOrHandle: string, name: string) => string
): string => {
if (plain) {
return val;
}
const value = serialize(parseFragment(val));
if (type === 'html') {

View File

@ -44,6 +44,7 @@ type PostWithConditionals = Post & {
childrenPost: Post[];
};
@Injectable()
export class PostsService {
private storage = UploadFactory.createStorage();
@ -478,6 +479,7 @@ export class PostsService {
p.content,
true,
false,
!(/<\/?[a-z][\s\S]*>/i.test(p.content)),
getIntegration.mentionFormat
),
settings: JSON.parse(p.settings || '{}'),