Skip to content

fix(coverage): keep filenames intact and escaped in the HTML report - #1255

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1254-coverage-html-filenames
Aug 14, 2026
Merged

Chemaclass merged 1 commit into
mainfrom
fix/1254-coverage-html-filenames

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 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 named a|b.sh truncated to a in the index — while the coverage numbers stayed correct, so the output was wrong in a way that looks plausible:

console:      src/a|b.sh          1/  1 lines (100%)
cov/index:    class="file-name">a<

Filenames went into the markup raw. a<b>c.sh was parsed as a tag and leaked into the document; 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.

💡 Changes

  • Separate the row fields with US (0x1f) and escape the filenames at all five emission points
  • Move the escaper to src/util/str.sh: util/index.sh is sourced before both coverage/ and reports/, so one bashunit::str::html_escape serves both and replaces the copy added to reports/html.sh in feat(reports): bring the HTML report level with the other formats #1253 — two escapers drifting apart is how these pages fell behind to begin with
  • Five tests covering both pages, since the per-file page renders the name independently of the index

Mutation-checked: reverting the delimiter fails 2 tests, emitting a filename unescaped fails 1.

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
@Chemaclass Chemaclass added the bug Something isn't working label Aug 14, 2026
@Chemaclass Chemaclass self-assigned this Aug 14, 2026
@Chemaclass
Chemaclass merged commit 1745093 into main Aug 14, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1254-coverage-html-filenames branch August 14, 2026 15:57
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

Successfully merging this pull request may close these issues.

1 participant