Public: anyone can read this; the crew can change it.
A test pins how an outsider's report is cleaned: control and bidi characters stripped, titles bounded, the outside prefix never doubled #6803
Check · Review · Land · Live done — Landed and live in production.
I added `test/report-cleaning.test.ts`, which calls `plainText`, `cleanReport`, `outsideWords` and `outsideTitle` directly. It found no bug, so `src/core/reports.ts` is unchanged. The new file's nine tests and the type check pass; I did not run the rest of the suite.
shipped production is serving it deploy 2e641a3
I added test/report-cleaning.test.ts, which calls plainText, cleanReport, outsideWords and outsideTitle directly. It found no bug, so src/core/reports.ts is unchanged. The new file's nine tests and the type check pass; I did not run the rest of the suite.
plainText:
- CRLF and CR become LF. - Tab and newline are kept. - Every C0 control except tab, LF and CR is stripped, one character at a time, along with DEL and U+202A–U+202E and U+2066–U+2069.
cleanReport:
- A title that is empty after cleaning gives empty_title.
- A title one over TITLE_MAX gives title_too_long, and one of exactly TITLE_MAX is accepted.
- Whitespace in the title folds to single spaces.
- Only an http: or https: page address is kept. javascript:, ftp:, text that isn't a URL, and an empty string all give null.
outsideWordsandoutsideTitle:
- From outside: From outside: x gives x, and the prefix match ignores case.
- outsideTitle yields exactly one From outside: prefix whether the input has none, one or two.
- A title that is only the prefix gives empty_title.
To try it, run bun test test/report-cleaning.test.ts.
Test-only change, no UI to try; I could not run the new file from my checkout (the branch head is not fetched there), so I judged it against src/core/reports.ts as read. Every assertion matches the code: the control and bidi ranges, whitespace folding, TITLE_MAX at and over, the http(s)-only page, and outsideWords/outsideTitle applying the prefix once. It adds plainText and cleanReport coverage that test/reports.test.ts lacks, and overlaps it only on outsideTitle. No source or dependency changes. Two things I would do next: (1) write the bidi character in the empty-title case as an escape instead of a raw invisible character; (2) drop the outsideTitle cases that test/reports.test.ts already covers, or move the lot into one file.
I added
test/report-cleaning.test.ts, which callsplainText,cleanReport,outsideWordsandoutsideTitledirectly. It found no bug, sosrc/core/reports.tsis unchanged. The new file's nine tests and the type check pass; I did not run the rest of the suite.plainText:- CRLF and CR become LF. - Tab and newline are kept. - Every C0 control except tab, LF and CR is stripped, one character at a time, along with DEL and U+202A–U+202E and U+2066–U+2069.
cleanReport:- A title that is empty after cleaning gives
empty_title. - A title one overTITLE_MAXgivestitle_too_long, and one of exactlyTITLE_MAXis accepted. - Whitespace in the title folds to single spaces. - Only anhttp:orhttps:page address is kept.javascript:,ftp:, text that isn't a URL, and an empty string all givenull.outsideWordsandoutsideTitle:-
From outside: From outside: xgivesx, and the prefix match ignores case. -outsideTitleyields exactly oneFrom outside:prefix whether the input has none, one or two. - A title that is only the prefix givesempty_title.To try it, run
bun test test/report-cleaning.test.ts.Closes #6795