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

[Bruno-cli] HTML Report fails to generate if API response contains JS replace sequences #3311

Open
2 tasks done
Iilun opened this issue Oct 15, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Iilun
Copy link

Iilun commented Oct 15, 2024

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

When an API response contains one of the replace special commands, the HTML report can generate invalid HTML.

In my specific case, the API answers with a string containing "$'", so the HTML reports duplicates the end part multiple times.

To reproduce, use the below bru file with an API answering with a "$'" anywhere.

Then use

bru run  --reporter-html results.html

The report is then invalid HTML

A simple fix would be, in the reporters/html.js file, to replace all $ in the results with $$ to prevent these sequences (this could have side effects)

const resultsJson = JSON.stringify(results, null, 2).replaceAll("$","$$$$");

.bru file to reproduce the bug

meta {
  name: Request a response
  type: http
  seq: 1
}

get {
  url: https://-an url sending the below body as a response-
  body: json
  auth: none
}

body:json {
  {
  "detail": "i will destroy the html report - regex is '^reportdestroyer$'"
  }
}

Screenshots/Live demo link

The request

image

The report

image

The HTML file (with bogus type so gh allows it) is here, we can see line 402 that the replace sequence has been replaced with HTML code

@Iilun Iilun added the bug Something isn't working label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant