diff --git a/src/components/translate-button.tsx b/src/components/translate-button.tsx index b386d8967..f047c30c4 100644 --- a/src/components/translate-button.tsx +++ b/src/components/translate-button.tsx @@ -31,7 +31,7 @@ const TranslateButton: React.FC = ({ status }) => { target_languages: targetLanguages, } = instance.pleroma.metadata.translation; - const renderTranslate = (me || allowUnauthenticated) && (allowRemote || status.account.local) && ['public', 'unlisted'].includes(status.visibility) && status.contentHtml.length > 0 && status.language !== null && intl.locale !== status.language; + const renderTranslate = (me || allowUnauthenticated) && (allowRemote || status.account.local) && ['public', 'unlisted'].includes(status.visibility) && status.content.length > 0 && status.language !== null && intl.locale !== status.language; const supportsLanguages = (!sourceLanguages || sourceLanguages.includes(status.language!)) && (!targetLanguages || targetLanguages.includes(intl.locale)); diff --git a/src/features/compose/components/reply-indicator.tsx b/src/features/compose/components/reply-indicator.tsx index 2b7bb5a15..dacdcf309 100644 --- a/src/features/compose/components/reply-indicator.tsx +++ b/src/features/compose/components/reply-indicator.tsx @@ -49,7 +49,7 @@ const ReplyIndicator: React.FC = ({ className, status, hideActi diff --git a/src/features/event/event-information.tsx b/src/features/event/event-information.tsx index 95796b934..0b01c27dd 100644 --- a/src/features/event/event-information.tsx +++ b/src/features/event/event-information.tsx @@ -195,7 +195,7 @@ const EventInformation: React.FC = ({ params }) => { return ( - {!!status.contentHtml.trim() && ( + {!!status.content.trim() && ( diff --git a/src/features/ui/components/modals/compare-history-modal.tsx b/src/features/ui/components/modals/compare-history-modal.tsx index 16bdf18d5..eb4ae960f 100644 --- a/src/features/ui/components/modals/compare-history-modal.tsx +++ b/src/features/ui/components/modals/compare-history-modal.tsx @@ -43,7 +43,7 @@ const CompareHistoryModal: React.FC = ({ onClose, statusId body = (
{versions?.map((version) => { - const content = { __html: version.contentHtml }; + const content = { __html: version.content }; const spoilerContent = { __html: version.spoilerHtml }; const poll = typeof version.poll !== 'string' && version.poll; diff --git a/src/normalizers/status.ts b/src/normalizers/status.ts index 376fd1384..ddca3e888 100644 --- a/src/normalizers/status.ts +++ b/src/normalizers/status.ts @@ -88,7 +88,6 @@ export const StatusRecord = ImmutableRecord({ event: null as ReturnType | null, // Internal fields - contentHtml: '', expectsCard: false, hidden: false, search_index: '', diff --git a/src/reducers/statuses.ts b/src/reducers/statuses.ts index 67c915177..64e6058cd 100644 --- a/src/reducers/statuses.ts +++ b/src/reducers/statuses.ts @@ -109,7 +109,6 @@ export const calculateStatus = ( if (oldStatus && oldStatus.content === status.content && oldStatus.spoiler_text === status.spoiler_text) { return status.merge({ search_index: oldStatus.search_index, - contentHtml: oldStatus.contentHtml, spoilerHtml: oldStatus.spoilerHtml, hidden: oldStatus.hidden, }); @@ -120,7 +119,7 @@ export const calculateStatus = ( return status.merge({ search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent || '', - contentHtml: DOMPurify.sanitize(stripCompatibilityFeatures(emojify(status.content, emojiMap)), { USE_PROFILES: { html: true } }), + content: DOMPurify.sanitize(stripCompatibilityFeatures(status.content), { USE_PROFILES: { html: true } }), spoilerHtml: DOMPurify.sanitize(emojify(escapeTextContentForBrowser(spoilerText), emojiMap), { USE_PROFILES: { html: true } }), hidden: expandSpoilers ? false : spoilerText.length > 0 || status.sensitive, }); diff --git a/src/schemas/status.ts b/src/schemas/status.ts index 6c04f28ee..1172b35ee 100644 --- a/src/schemas/status.ts +++ b/src/schemas/status.ts @@ -1,4 +1,5 @@ import escapeTextContentForBrowser from 'escape-html'; +import DOMPurify from 'isomorphic-dompurify'; import { z } from 'zod'; import emojify from 'soapbox/features/emoji/index.ts'; @@ -106,13 +107,13 @@ type Translation = { const transformStatus = ({ pleroma, ...status }: T) => { const emojiMap = makeCustomEmojiMap(status.emojis); - const contentHtml = stripCompatibilityFeatures(emojify(status.content, emojiMap)); + const content = DOMPurify.sanitize(stripCompatibilityFeatures(status.content), { USE_PROFILES: { html: true } }); const spoilerHtml = emojify(escapeTextContentForBrowser(status.spoiler_text), emojiMap); return { ...status, approval_status: 'approval' as const, - contentHtml, + content, expectsCard: false, event: pleroma?.event, filtered: [],