fix(app): set lone-surrogate texts aside or refuse them with a message (L1)

A draft the core refuses as lone_surrogate is unreadable content: it
goes to osteo:quarantine:draft verbatim with the existing notice. An
import is refused as ImportError('lone_surrogate') with the owner's
wording (home.import.error_lone_surrogate, FR/EN), the file untouched.
The publish gate reads the kind as invalid_shape. Tests on the real
core: quarantine keeps the exact text, an editor action leaves the
report as it was, normal text with pairs and literal backslashes reads
unchanged.
This commit is contained in:
bchanot committed 2026-10-14 21:49:39 +02:00
1 parent 20d03cf7fd
commit da8a0370cb
12 files changed
+151 -11

No files matched your search

+12 -2
View File
@@ -8,7 +8,14 @@ import type { SheetIndex } from '@/services/sheetIndex'
export { MAX_PDF_BYTES } from '@faunosteo/pdf'
export type ImportErrorKind = ArchiveReadErrorKind | 'core_unavailable'
/**
* `lone_surrogate`: the attachment escapes a lone UTF-16 surrogate, which the
* core cannot read without altering it (L1): refused, the file untouched.
*/
export type ImportErrorKind =
| ArchiveReadErrorKind
| 'core_unavailable'
| 'lone_surrogate'
/**
* Localization-agnostic import error. Carries a kind discriminant + an
@@ -46,7 +53,8 @@ export async function readAttachment(pdfBytes: Uint8Array): Promise<unknown> {
* attachment (report first, v2 migrated through the sheet's map, then the
* envelope kept or its snapshot dropped with a reason) and the rebase onto
* that sheet. An unknown numeric report version is `incompatible_version`,
* any other unreadable content `no_attachment`, as the engine reported them.
* a text the core would alter `lone_surrogate`, any other unreadable content
* `no_attachment`, as the engine reported them.
*/
export function importAttachment(
attachment: unknown,
@@ -59,6 +67,8 @@ export function importAttachment(
throw new ImportError('incompatible_version', outcome.found ?? null)
case 'no_attachment':
throw new ImportError('no_attachment')
case 'lone_surrogate':
throw new ImportError('lone_surrogate')
case 'core_unavailable':
case 'internal':
throw new ImportError('core_unavailable')