Repository navigation
Conversation
| } else if (type == JupyterOutputType.TEXT_HTML) { | ||
| // MathJax also interprets content, so skip it for untrusted saved output. | ||
| outputData = "<div class=\"tex2jax_ignore\">" + ImportedHtml.clean(outputData) + "</div>"; | ||
| } | ||
| return result; | ||
| return new TypeData(type.getZeppelinType().toString(), outputData); |
There was a problem hiding this comment.
Could we try the next MIME candidate when sanitization leaves the HTML preview empty? For example, if a bundle contains a canvas-only HTML preview and a PNG snapshot, we select the HTML first and end up rendering an empty <div>, even though the bundle already contains a usable image. We can keep preferring HTML when it survives sanitization and fall back to the next candidate when it doesn't.
| + "{\"output_type\":\"display_data\",\"data\":{" | ||
| + "\"text/html\":\"<b>preferred</b>\",\"text/plain\":\"fallback\"," | ||
| + "\"application/javascript\":\"alert(1)\"}}," |
There was a problem hiding this comment.
Could we test the same MIME bundle with the keys in reverse order as well? The current fixture puts text/html first, so an implementation that simply picks the first supported key would also pass. Asserting that both orders select HTML would verify that the declared priority, not the input key order, determines the preview.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the notebook import hardening changes.
No open issues 🎉
What changed in this PR
This hotfix hardens Zeppelin’s Jupyter notebook imports by converting saved markdown and rich output into sanitized, static previews while preserving cell source.
Changes:
- Sanitize HTML previews and disable MathJax processing; render SVG as encoded images and JavaScript/LaTeX as text.
- Apply deterministic MIME selection with fallback handling and native PNG results.
- Add import regression coverage and update jsoup dependency and license metadata.
| File | Description |
|---|---|
zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookImportTest.java |
Adds server-level coverage for sanitized imports and preserved source. |
zeppelin-server/pom.xml |
Removes the jsoup exclusion. |
zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java |
Tests sanitization, MIME priority, fallbacks, and source preservation. |
zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java |
Adds the IMG output type. |
zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java |
Maps PNG to images and JavaScript/LaTeX to text. |
zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/parser/MarkdownParser.java |
Sanitizes rendered markdown and disables MathJax processing. |
zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/parser/ImportedHtml.java |
Adds shared HTML sanitization and renderable-content checks. |
zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java |
Normalizes rich output and applies deterministic MIME selection. |
zeppelin-jupyter/pom.xml |
Adds an explicit jsoup 1.24.1 dependency. |
zeppelin-distribution/src/bin_license/licenses/LICENSE-jsoup-1.24.1 |
Adds the jsoup 1.24.1 license text. |
zeppelin-distribution/src/bin_license/licenses/LICENSE-jsoup-1.16.1 |
Corrects existing jsoup copyright metadata and formatting. |
zeppelin-distribution/src/bin_license/LICENSE |
Lists jsoup 1.24.1 in the bundled license inventory. |
Review effort: Balanced
|
LGTM, thanks for addressing both comments! |
61fa99d to
9ee0f0c
Compare
What is this PR for?
Jupyter notebook imports convert saved markdown and rich output into Zeppelin result previews. This PR sanitizes imported HTML previews, renders SVG output as encoded images, keeps JavaScript and LaTeX output as text, applies deterministic MIME display priority, and updates the jsoup dependency and license metadata. Imported cell source remains unchanged.
What type of PR is it?
Hot Fix
Todos
What is the Jira issue?
N/A
How should this be tested?
./mvnw -B -T1 -pl zeppelin-jupyter --am test -Dtest=JupyterUtilTest -Dsurefire.failIfNoSpecifiedTests=false./mvnw -B -T1 -pl zeppelin-server --am test -Dtest=NotebookImportTest -Dsurefire.failIfNoSpecifiedTests=false./mvnw -B -T1 -DskipTests -Prat org.apache.rat:apache-rat-plugin:checkScreenshots (if appropriate)
N/A
Questions: