fix(pdf): report:compare --diff follows the privacy default, generic reason on a malformed attachment, Unicode control and format characters escaped, regular files only
This commit is contained in:
1 parent
b1b3e4927e
commit
388e209ea9
4 files changed
+48
-20
No files matched your search
@@ -46,14 +46,15 @@ export interface Counts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes C0, DEL and C1 control characters as `\uXXXX` (newline and
|
||||
* carriage return included): a PDF is untrusted, and a raw escape sequence
|
||||
* printed to a terminal can rewrite the screen or fake a line.
|
||||
* Escapes Unicode control (C0, DEL, C1) and format characters (bidi
|
||||
* overrides, zero-width) plus the line and paragraph separators as `\uXXXX`
|
||||
* (newline and carriage return included): a PDF is untrusted, and a raw
|
||||
* escape sequence printed to a terminal can rewrite the screen or fake a line.
|
||||
*/
|
||||
export function esc(text: string): string {
|
||||
return text.replace(
|
||||
/[\u0000-\u001f\u007f-\u009f]/g,
|
||||
(c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`,
|
||||
/[\p{Cc}\p{Cf}\u2028\u2029]/gu,
|
||||
(c) => `\\u${c.codePointAt(0)!.toString(16).padStart(4, '0')}`,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -287,11 +288,10 @@ export function compareReport(
|
||||
const v3Lines = report.observations.map((o) =>
|
||||
observationLines(o, sheet, opts),
|
||||
)
|
||||
// A diff must see a lost conclusion: its lines always carry the full texts.
|
||||
const fullOpts = { ...opts, full: true }
|
||||
// Same privacy default as the listing: texts are compared with `--full`.
|
||||
const normalized = [
|
||||
...report.observations.flatMap((o) => observationLines(o, sheet, fullOpts)),
|
||||
...footerLines(report, true),
|
||||
...report.observations.flatMap((o) => observationLines(o, sheet, opts)),
|
||||
...footerLines(report, opts.full),
|
||||
]
|
||||
return {
|
||||
source,
|
||||
|
||||
Reference in new issue
Block a user