Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML in children is not sanitized within collapsed component #33

Open
glennpow opened this issue Aug 14, 2021 · 5 comments
Open

HTML in children is not sanitized within collapsed component #33

glennpow opened this issue Aug 14, 2021 · 5 comments

Comments

@glennpow
Copy link

When ShowMoreText is collapsed, then any HTML tags that are present in the children (not as JSX, but as a raw string) are not sanitized properly. It appears that this happens in the Truncate inner component logic. This is a problem for us, since we do occasionally have HTML in our text, which we want to remain raw (not rendered).

Example

    const line = "<b>Test</b>\n";
    let content = "";
    for (var i = 0; i < 20; i++) {
      content += line;
    }

    return (
      <ShowMoreText
        expanded={false}
        keepNewLines={true}
        lines={5}
      >
        {content}
      </ShowMoreText>
    );

Collapsed

image

Expanded

image

@MelonBall
Copy link

We have the same problem, as in the HTML rendering doesn't have the same behaviour in collapsed vs. non-collapsed form.

@JohnGeorgiadis
Copy link

Hello :)
did anyone found a solution for this yet? I am facing the same issue.

@ronmara
Copy link

ronmara commented Nov 3, 2021

try this:

<ShowMoreText
    expanded={false}
    keepNewLines={true}
    lines={5}
>
    <div
        dangerouslySetInnerHTML={{
            __html: content,
        }}
    />
</ShowMoreText>

@MelonBall
Copy link

try this:

<ShowMoreText
    expanded={false}
    keepNewLines={true}
    lines={5}
>
    <div
        dangerouslySetInnerHTML={{
            __html: content,
        }}
    />
</ShowMoreText>

Then we have the reverse : the collapsed form will have the HTML tags and the non collapsed form will be formated.

@Razhelq
Copy link

Razhelq commented Jan 18, 2022

Hi. The issue still persists. Any luck fixing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants