-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
fix: support custom links in markdown #26211
fix: support custom links in markdown #26211
Conversation
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.
LGTM
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #26211 +/- ##
=======================================
Coverage 69.19% 69.19%
=======================================
Files 1945 1945
Lines 75928 75928
Branches 8453 8453
=======================================
Hits 52537 52537
Misses 21207 21207
Partials 2184 2184
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
(cherry picked from commit d2adc85)
(cherry picked from commit d2adc85)
(cherry picked from commit d2adc85)
SUMMARY
Currently it's not possible to use links to custom protocols, despite adding them to
HTML_SANITIZATION_SCHEMA_EXTENSIONS["protocols"]
insuperset_config.py
. This is due to the fact thatReactMarkdown
has built-in link sanitization functionality that's overlapping with therehypePlugins
that we're using.As we're already using
rehype
to sanitize the markdown, it makes sense to disable the built-in sanitization. This can be done by settingtransformLinkUri={null}
. Here's what ChatGPT said about the change:Me:
ChatGPT:
Originally, I wanted to add a RTL test that ensures the links render correctly with this change. However, we've had to disable
react-markdown
and therehype
libraries in our test suites due to ESM incompatibility with Jest:superset/superset-frontend/spec/helpers/shim.tsx
Lines 87 to 90 in b4a35e6
For this reason we're unable to add proper tests for
react-markdown
before it either adds CJS, or Jest fully supports ESM. I'm bumping Jest in the following PR to a more recent version: #26182 However, unfortunately this version doesn't yet work correctly with ESM, so it seems we may need to wait a while longer before this test can be added.TESTING INSTRUCTIONS
superset_config.py
:HTML_SANITIZATION_SCHEMA_EXTENSIONS = {"protocols": {"href": ["foo"] } }
foo://bar
and another one withxyz://qwerty
javascript:void()
foo://bar
as expected, and the other one is completely missing ahref
thanks to our rehype sanitizationADDITIONAL INFORMATION