jupyter / jupyter/notebook

Markdown output not shown for Untrusted Notebooks

Open
#4,339 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I'm using `IPython.core.display.Markdown` to dynamically generate markdown content in a notebook. When I use a tool to update the notebook, such as `jupyter nbconvert`, the Notebook may become [untrusted](https://jupyter-notebook.readthedocs.io/en/stable/notebook.html#trusting-notebooks) for the server. In that case it only shows the `text/plain` part of the output.

In the console I am seeing `Ignoring untrusted text/markdown output.` The [code](https://github.com/jupyter/notebook/blob/b8b66332e2023e83d2ee04f83d8814f567e01a4e/notebook/static/notebook/js/outputarea.js#L692) shows that it would sanitize HTML but not Markdown. I understand that Markdown can be converted to HTML and that it itself can contain HTML. Here I would expect it to be able to sanitize Markdown as well (e.g. by conversion to HTML and displaying the sanitized HTML).

The cells with a Markdown type seem to display fine. Not sure whether they get sanitized.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in notebook/static/notebook/js/outputarea.js around the linked untrusted-output handling, and reproduce the case with IPython.core.display.Markdown in a notebook made untrusted by nbconvert. Compare it with how notebook Markdown cells are displayed. Done means untrusted Markdown output is safely sanitized and shown instead of only its text/plain part.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jupyter-notebook
Domain
frontend, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.