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

Tag SCRIPT breaks whole document #652

Open
xdan opened this issue Mar 1, 2025 · 0 comments
Open

Tag SCRIPT breaks whole document #652

xdan opened this issue Mar 1, 2025 · 0 comments

Comments

@xdan
Copy link

xdan commented Mar 1, 2025

Package version

4.47.3

Node version

20.16

Platform

mac

What steps will reproduce the bug?

allowHTML: true
needToSanitizeHtml: false

If you use html in a page + allow inserting script, the page becomes broken. You insert all the content into the script tag at the end of the document

# Example 1
<script>bla()</script>

After build this script will be inside another script in the end of the page

<script type="application/javascript">
window.STATIC_CONTENT = true
                   window.__DATA__ = {"data": ...., html: "...<script>bla()</script>"
</script>

when the browser parser encounters another script tag inside, it thinks that the first one has ended.

What is the expected behavior?

For documentation it is often important to include examples, I would like to be able to include a script tag

What do you see instead?

Broken page

Additional information

I also couldn't find what format the sanitizer options are (sanitizeOptions). The documentation just says Object.
I think it should be like this:

allowHTML: true
needToSanitizeHtml: true
sanitizeOptions:
    allowedTags: 
        - script

But this does't work

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

1 participant