diff --git a/src/components/challenge-modal/__tests__/challenge-modal.test.tsx b/src/components/challenge-modal/__tests__/challenge-modal.test.tsx index 50c494e2..bdde3b4e 100644 --- a/src/components/challenge-modal/__tests__/challenge-modal.test.tsx +++ b/src/components/challenge-modal/__tests__/challenge-modal.test.tsx @@ -226,6 +226,30 @@ describe('ChallengeModal', () => { expect(testState.removeChallengeMock).toHaveBeenCalledOnce(); }); + it('redacts generated fortune BBCode from challenge publication details', async () => { + const publication = { + ...createPublication(), + content: 'body[fortune color=#fd4d32]Excellent Luck[/fortune]', + }; + testState.publicationPreview = 'body'; + testState.publicationType = 'post'; + testState.challenges = [ + createStoredChallenge( + { + challenge: '2 + 2', + type: 'text/plain', + }, + publication, + ), + ]; + + await renderModal(); + + expect(container.querySelector('textarea')?.value).toBe('body'); + expect(container.textContent).not.toContain('Excellent Luck'); + expect(container.textContent).not.toContain('[fortune'); + }); + it('supports multi-step image challenges with next and previous navigation', async () => { const publication = createPublication(); testState.challenges = [ diff --git a/src/components/challenge-modal/challenge-modal.tsx b/src/components/challenge-modal/challenge-modal.tsx index d1fd7ad6..6a5ffafb 100644 --- a/src/components/challenge-modal/challenge-modal.tsx +++ b/src/components/challenge-modal/challenge-modal.tsx @@ -2,6 +2,7 @@ import { useRef, useState, useEffect, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { Challenge as ChallengeType, useAccount, useComment } from '@bitsocial/bitsocial-react-hooks'; import { getPublicationPreview, getPublicationType, getVotePreview } from '../../lib/utils/challenge-utils'; +import { stripGeneratedFortuneMarkup } from '../../lib/utils/post-options-utils'; import useIsMobile from '../../hooks/use-is-mobile'; import useChallengesStore from '../../stores/use-challenges-store'; import useTrustedBoardUrlPermissionsStore from '../../stores/use-trusted-board-url-permissions-store'; @@ -325,6 +326,7 @@ const Challenge = ({ challenge, closeModal, abandonModal }: ChallengeProps) => { const votePreview = getVotePreview(publication); const { author, content, link, title, parentCid, shortCommunityAddress, communityAddress } = publication || {}; + const visibleContent = content ? stripGeneratedFortuneMarkup(content) : ''; const { displayName } = author || {}; const parentAddress = useParentAddress(parentCid); const community = shortCommunityAddress || communityAddress; @@ -493,9 +495,9 @@ const Challenge = ({ challenge, closeModal, abandonModal }: ChallengeProps) => { )} - {content && ( + {visibleContent && (
-