Sanitize tracker summaries
The summaries can include invalid html tags which caused issues when trying to render them since these tags do not exist. Known issue: The invalid tags will get escaped, however, when they include a space (e.g. "<Author's Notes>" everything after the space is missing (e.g. will be "<Author's>")
This commit is contained in:
@@ -23,6 +23,7 @@ import parseHtml from 'html-react-parser';
|
||||
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
import useMediaQuery from '@mui/material/useMediaQuery';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
import { SpinnerImage } from '@/components/util/SpinnerImage.tsx';
|
||||
import { TrackerManga } from '@/lib/data/Trackers.ts';
|
||||
import { TypographyMaxLines } from '@/components/atoms/TypographyMaxLines.tsx';
|
||||
@@ -64,13 +65,12 @@ const TrackerMangaCardSummary = ({ summary }: { summary: string }) => {
|
||||
setShowSummaryExpandButton(shouldCollapseSummary);
|
||||
setIsSummaryExpanded(!shouldCollapseSummary);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{summary.length && (
|
||||
<Collapse collapsedSize={summaryCollapsedSize} in={isSummaryExpanded}>
|
||||
<Typography ref={summaryRef} variant="body1" component="p">
|
||||
{parseHtml(summary)}
|
||||
{parseHtml(sanitizeHtml(summary, { disallowedTagsMode: 'escape' }))}
|
||||
</Typography>
|
||||
</Collapse>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user