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:
1 parent
20d03cf7fd
commit
da8a0370cb
12 files changed
+151
-11
No files matched your search
@@ -53,7 +53,7 @@ export interface ActionResult {
|
||||
/** What a draft restore did; `null` from the action when there was nothing to restore. */
|
||||
export type RestoreResult =
|
||||
| { kind: 'restored'; rebase: RebaseOutcome }
|
||||
/** The draft is unreadable by this build: set aside under a quarantine key. */
|
||||
/** The draft is unreadable by this build: set aside, verbatim, under a quarantine key. */
|
||||
| { kind: 'quarantined' }
|
||||
/**
|
||||
* The draft is unreadable but could not be set aside (storage full): it stays in
|
||||
@@ -123,6 +123,17 @@ function applyCore(
|
||||
return OK
|
||||
}
|
||||
|
||||
/**
|
||||
* The core's content kinds for a draft: the text itself is unreadable by this build
|
||||
* (`lone_surrogate`: reading it would alter a string, L1). Any other failure is the core's
|
||||
* or the sheet's and leaves the draft in place.
|
||||
*/
|
||||
const UNREADABLE_DRAFT_KINDS: ReadonlySet<string> = new Set([
|
||||
'invalid',
|
||||
'unsupported_version',
|
||||
'lone_surrogate',
|
||||
])
|
||||
|
||||
/** Reads the draft through the core; unreadable content goes to quarantine, never away. */
|
||||
function restore(
|
||||
index: SheetIndex,
|
||||
@@ -135,7 +146,7 @@ function restore(
|
||||
const outcome = index.ops.restoreDraft(draft, archiveText)
|
||||
if (!outcome.ok) {
|
||||
// Only an unreadable draft is set aside; a core or sheet failure leaves it in place.
|
||||
if (outcome.kind !== 'invalid' && outcome.kind !== 'unsupported_version') {
|
||||
if (!UNREADABLE_DRAFT_KINDS.has(outcome.kind)) {
|
||||
return { result: { kind: 'core_unavailable' } }
|
||||
}
|
||||
const setAside = quarantine('draft', draft, DRAFT_KEY)
|
||||
|
||||
Reference in new issue
Block a user