Skip to content
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

HTML content in test report is not escaped properly in VItest UI #5321

Closed
6 tasks done
BlankParticle opened this issue Mar 1, 2024 · 1 comment · Fixed by #5325
Closed
6 tasks done

HTML content in test report is not escaped properly in VItest UI #5321

BlankParticle opened this issue Mar 1, 2024 · 1 comment · Fixed by #5325
Labels
feat: ui Vitest UI p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@BlankParticle
Copy link

Describe the bug

I have a few tests that compares HTML content. It shows the HTML diff as needed in console. But the HTML content is not not escaped and renders as html instead of text. This allows one to arbitrarily inject any html element in the web reporter.

Personally, I don't think executing arbitrary script in vitest web ui is any big deal, but its annoying while trying to see the errors.

Reproduction

The reproduction is at https://stackblitz.com/edit/vitest-dev-vitest-fgckzr?file=test%2Fhtml.test.ts&initialPath=__vitest__/

for the script and style to be injected, open the first test fail report

It should apply a green border to everything and show an alert
image

System Info

System:
    OS: Linux 6.6 Pop!_OS 22.04 LTS
    CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Memory: 2.14 GB / 5.66 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.local/share/pnpm/node
    npm: 10.2.4 - ~/.local/share/pnpm/npm
    pnpm: 8.15.4 - ~/.local/share/pnpm/pnpm
    bun: 1.0.29 - ~/.bun/bin/bun
  Browsers:
    Chrome: 122.0.6261.94
  npmPackages:
    @vitest/ui: ^1.3.1 => 1.3.1 
    vitest: ^1.3.1 => 1.3.1

Used Package Manager

pnpm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Mar 2, 2024

Oh, you got a nice reproduction. I thought html escape issue is fixed by #4724, but maybe it's missing for diff output.

@hi-ogawa hi-ogawa added feat: ui Vitest UI p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Mar 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: ui Vitest UI p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants