镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix: escape job stdout and stderr before rendering ANSI colors as HTML - #9587

Open
RaphaelFakhri wants to merge 1 commit into
OpenMined:devfrom
RaphaelFakhri:fix/job-stdout-html-escape
Open

RaphaelFakhri wants to merge 1 commit into
OpenMined:devfrom
RaphaelFakhri:fix/job-stdout-html-escape

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

Fixes #9586. The notebook views of job.stdout and job.stderr escaped quotes after they built the ANSI color spans, which broke every style attribute. They never escaped < and >, so output such as <class 'int'> or a traceback's in <module> was parsed as HTML and disappeared.

Changes

  • StdoutViewer._repr_html_ and StderrViewer._repr_html_ now escape the raw job output with html.escape first, then convert ANSI codes to <span> elements. ANSI sequences contain no HTML special characters, so they survive escaping.
  • Removed the manual &, " and ' replacements that ran after the span conversion.
  • Added packages/syft-job/tests/test_job_stdout.py with tests for escaped output and intact color spans in both viewers.

Testing

  • pytest packages/syft-job/tests: 3 new tests fail before the fix; 163 passed after it.
  • ruff check and ruff format --check (v0.12.9) pass on packages/syft-job/.

Asana task

  • Not applicable (external contribution).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

syft-job: job stdout and stderr HTML views drop <...> text and show no ANSI colors

1 participant