Skip to content

Escape user content in notebook HTML - #155

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:codex/issue-120
Open

Escape user content in notebook HTML#155
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:codex/issue-120

Conversation

@njzjz-bot

Copy link
Copy Markdown
Contributor

Summary

  • HTML-escape rendered JSON keys and values
  • escape generated tooltip text before restoring supported formatting
  • add injection regression coverage for keys, values, and docs

Fixes #120.

Validation

  • python -m unittest -v tests.test_notebook with IPython display imports available
  • Ruff checks on changed files

AI attribution

Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh

Coding-Agent: Codex
Codex-Version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning-Effort: xhigh
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 63e56341-0e70-4b98-a7bd-5477877eb50b


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: one medium-severity issue found.

The user-content escaping closes the intended injection paths, but the escaping order introduces a tooltip-formatting regression. See the inline suggestion.

I reproduced the literal <br/> output with the PR head; the security-focused tests and CI otherwise pass.

Coding agent: Codex
Codex version: codex-cli 0.149.0
Model: gpt-5.6-sol
Reasoning effort: xhigh

Comment thread dargs/notebook.py
)
# Escape generated text before selectively restoring the small
# set of formatting markers supported by the tooltip.
doc_head = html.escape(doc_head, quote=False)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Escape before inserting the trusted line-break markup

doc_head has already converted newlines into <br/> before this call, so html.escape() turns every intended tooltip line break into visible &lt;br/&gt; text. I reproduced output such as child: &lt;br/&gt; type: .... Recompute from the unformatted generated text, escape it, and only then add renderer-owned line breaks:

Suggested change
doc_head = html.escape(doc_head, quote=False)
doc_head = html.escape(
self.arg.gen_doc_head().replace("| type:", "type:"),
quote=False,
).replace("\n", linebreak)

After applying this suggestion, the earlier doc_head assignment at lines 274–278 is redundant and should be removed.

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

Successfully merging this pull request may close these issues.

[Code scan] Notebook HTML renderer does not escape JSON content

1 participant