mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-11 18:16:58 +00:00
fix(ui) Sanitize V1 UI sidebar description section (#13203)
This commit is contained in:
parent
319b849532
commit
3fd0e37111
@ -2,6 +2,7 @@ import { Typography } from 'antd';
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import { useHistory } from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
|
import DOMPurify from 'dompurify';
|
||||||
import CompactContext from '../../../../../../shared/CompactContext';
|
import CompactContext from '../../../../../../shared/CompactContext';
|
||||||
import MarkdownViewer, { MarkdownView } from '../../../../components/legacy/MarkdownViewer';
|
import MarkdownViewer, { MarkdownView } from '../../../../components/legacy/MarkdownViewer';
|
||||||
import NoMarkdownViewer, { removeMarkdown } from '../../../../components/styled/StripMarkdownText';
|
import NoMarkdownViewer, { removeMarkdown } from '../../../../components/styled/StripMarkdownText';
|
||||||
@ -68,12 +69,15 @@ export default function DescriptionSection({ description, baDescription, isExpan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sanitizedDescription = DOMPurify.sanitize(description);
|
||||||
|
const sanitizedBADescription = DOMPurify.sanitize(baDescription || '');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ContentWrapper>
|
<ContentWrapper>
|
||||||
{isExpanded && (
|
{isExpanded && (
|
||||||
<>
|
<>
|
||||||
<MarkdownViewer source={description} ignoreLimit />
|
<MarkdownViewer source={sanitizedDescription} ignoreLimit />
|
||||||
{isOverLimit && (
|
{isOverLimit && (
|
||||||
<Typography.Link onClick={() => setIsExpanded(false)}>Read Less</Typography.Link>
|
<Typography.Link onClick={() => setIsExpanded(false)}>Read Less</Typography.Link>
|
||||||
)}
|
)}
|
||||||
@ -89,14 +93,14 @@ export default function DescriptionSection({ description, baDescription, isExpan
|
|||||||
}
|
}
|
||||||
shouldWrap
|
shouldWrap
|
||||||
>
|
>
|
||||||
{description}
|
{sanitizedDescription}
|
||||||
</NoMarkdownViewer>
|
</NoMarkdownViewer>
|
||||||
)}
|
)}
|
||||||
</ContentWrapper>
|
</ContentWrapper>
|
||||||
<BaContentWrapper>
|
<BaContentWrapper>
|
||||||
{isBaExpanded && (
|
{isBaExpanded && (
|
||||||
<>
|
<>
|
||||||
<MarkdownViewer source={baDescription || ''} ignoreLimit />
|
<MarkdownViewer source={sanitizedBADescription || ''} ignoreLimit />
|
||||||
{isBaOverLimit && (
|
{isBaOverLimit && (
|
||||||
<Typography.Link onClick={() => setIsBaExpanded(false)}>Read Less</Typography.Link>
|
<Typography.Link onClick={() => setIsBaExpanded(false)}>Read Less</Typography.Link>
|
||||||
)}
|
)}
|
||||||
@ -112,7 +116,7 @@ export default function DescriptionSection({ description, baDescription, isExpan
|
|||||||
}
|
}
|
||||||
shouldWrap
|
shouldWrap
|
||||||
>
|
>
|
||||||
{baDescription}
|
{sanitizedBADescription}
|
||||||
</NoMarkdownViewer>
|
</NoMarkdownViewer>
|
||||||
)}
|
)}
|
||||||
</BaContentWrapper>
|
</BaContentWrapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user