-
Notifications
You must be signed in to change notification settings - Fork 4k
[feat] Add frontend for executing JS in st.html #12918
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
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the HTML component to support unsafe JavaScript execution through a new unsafeAllowJavascript flag. The implementation splits HTML rendering into two paths: sanitized HTML (existing behavior) and HTML with JavaScript execution enabled (new behavior).
Key changes:
- Extracted DOMPurify hooks into a shared
dompurifyHooks.tsmodule for reuse - Split the main
Htmlcomponent into three specialized components:SanitizedHtml,HtmlWithJs, andHtmlContainer - Added comprehensive test coverage for both sanitization and JavaScript execution paths
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/src/test_util.tsx | Changed mock function from vi.fn() to empty arrow function for setFullScreen |
| frontend/lib/src/components/elements/Html/dompurifyHooks.ts | Extracted DOMPurify hooks for target="_blank" link handling into a centralized module |
| frontend/lib/src/components/elements/Html/SanitizedHtml.tsx | Created new component for sanitized HTML rendering without JavaScript |
| frontend/lib/src/components/elements/Html/HtmlWithJs.tsx | Created new component that sanitizes but preserves and executes script tags |
| frontend/lib/src/components/elements/Html/HtmlContainer.tsx | Created shared container component wrapping StyledHtml with common props |
| frontend/lib/src/components/elements/Html/Html.tsx | Refactored to route to either SanitizedHtml or HtmlWithJs based on unsafeAllowJavascript flag |
| frontend/lib/src/components/elements/Html/Html.test.tsx | Comprehensive test suite covering both sanitization and JavaScript execution paths |
e54803e to
461b031
Compare
9ad33c4 to
0ade7e7
Compare
461b031 to
0aefd4e
Compare
0aefd4e to
a6334cb
Compare
0ade7e7 to
d276838
Compare
d276838 to
89d39c5
Compare
a6334cb to
a806dd8
Compare
Merge activity
|
a806dd8 to
622ffb2
Compare

Describe your changes
Refactored the HTML component to properly handle JavaScript execution when
unsafeAllowJavascriptis enabled. The implementation now:SanitizedHtmlandHtmlWithJsTesting Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.