fix(coverage): keep filenames intact and escaped in the HTML report - #1255
Merged
Merged
Conversation
The coverage pages carried both defects the test report had, independently. Rows were built as "$display_file|$hit|..." and split back with IFS='|', so a source file named a|b.sh truncated to `a` in the index -- while the coverage numbers stayed correct, which is the kind of wrong output that looks fine. Filenames also went into the markup raw: a<b>c.sh was parsed as a tag and leaked into the document, and read&write.sh was invalid entity syntax. html_file.sh's awk escape() covers the source lines it renders and rightly omits `"` for element content -- it was only the filenames, in the index link and path and in the per-file page's title and two spans. Separate the fields with US (0x1f) and escape the names. The escaper moves to src/util/str.sh: util/index.sh is sourced before both coverage/ and reports/, so one bashunit::str::html_escape serves them and replaces the copy added to reports/html.sh, rather than leaving two to drift apart again -- which is how these pages fell behind in the first place. Closes #1254
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1254
The coverage pages carried both defects fixed in the test report (#1249), independently.
Rows were joined and split on
|. A source file nameda|b.shtruncated toain the index — while the coverage numbers stayed correct, so the output was wrong in a way that looks plausible:Filenames went into the markup raw.
a<b>c.shwas parsed as a tag and leaked into the document;read&write.shwas invalid entity syntax.html_file.sh's awkescape()covers the source lines it renders and rightly omits"for element content — it was only the filenames, in the index link and path and in the per-file page's<title>and two spans.💡 Changes
src/util/str.sh:util/index.shis sourced before bothcoverage/andreports/, so onebashunit::str::html_escapeserves both and replaces the copy added toreports/html.shin feat(reports): bring the HTML report level with the other formats #1253 — two escapers drifting apart is how these pages fell behind to begin withMutation-checked: reverting the delimiter fails 2 tests, emitting a filename unescaped fails 1.