cucumber / html-formatter

HTML formatter for reporting Cucumber results
https://cucumber.io/
MIT License
13 stars 4 forks source link

Html formatter breaks when step has </script> text #311

Closed denis-zhdanov closed 1 month ago

denis-zhdanov commented 2 months ago

👓 What did you see?

Given a step like below:

    When HTTP PUT request to /bulk/payroll/<bound:bulk-payroll-id>/v1 is made with JSON body:
      """
      {
        "expectedExecutionDateUtc": "2100-11-28T00:00:00.000Z",
        "notes": "<script>doSomethingBad() {}</script>",
        "action": "START_REVIEW"
      }
      """

When a test with it is executed, the html report is broken. If we take a look into the generated html, it looks like this:

<script>
window.CUCUMBER_MESSAGES = [{...\"<script>doSomethingBad() {}</script>"\", \n# \"action\": \"START_REVIEW\"...</script>

Eventual HTML report was corrupted

✅ What did you expect to see?

a correct HTML report

📦 Which tool/library version are you using?

java 21 cucumber 7.18.0

🔬 How could we reproduce it?

use a step like above with an html report plugin

📚 Any additional context?

No response

mpkorstanje commented 2 months ago

@davidjgoss as we're only dealing with json replacing all instances of / with \/ should be sufficient right?