Important - HTML does not get escaped in failed test reports
See original GitHub issueDescribe the bug
If tests fails, a user (student, tutor, instructor) can click on the underlined x of y passing
to see more details. A modal opens up and shows the error that got reported. In case of JUnit, the error looks like this internally:
expected:<Nieder mit den Eisb[ä]ren!> but was:<Nieder mit den Eisb[�]ren!>
This however is not what is shown:
Because it is not escaped, and transforms into (partly by the browser):
This can easily be further extended to:
and could lead to big problems, in addition to students not getting a helpful error message.
To Reproduce
- Create Java programming exercise
- Set it up to test for String equality (no String can contain linebreaks, otherwise the HTML is rendered differently - but still wrong - again) using
assertEquals
- Solve the exercise and make a mistake, but only in the middle of the String (because <[… seems to be no problem to display)
- Submit and take a look at the report shown by artemis, also using the dev-view of the web browser
Expected behavior
HTML special characters must be escaped.
Environment
- OS: Windows 10 (1903) - Browser Vivaldi (2.8; Chromium 77 based)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to escape HTML - javascript - Stack Overflow
No, once the text is in the DOM, the concept of "escaping" it doesn't apply. The HTML source text needs to be escaped...
Read more >Summarized test results: HTML escapes - W3C
To see detailed results for a single test, click on the link in the Details column and look just above the table. The...
Read more >simpletest_log_read() does not escape error messages [#2415671 ...
Enable the Simpletest module. Log in as administrator. Go to admin/config/development/testing and run the ExceptionHandlingTest. When the test results are ...
Read more >10.1. Preventing Cross Site Scripting Vulnerabilities
Escape always. Assume that all data is untrusted and escape it appropriately. Do not try to determine whether data could or could not...
Read more >Auto-escaping and output formats - Apache FreeMarker Manual
A value of that type is a piece of text that's already in the output format (like HTML), and hence needs no further...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @MaisiKoleni, yes, planning to release this today.
I thank all of you very much for the fast fix. I assume this will be integrated in the maintenance today? Because that would allow me to remove some workarounds. And thanks again.