{"version":73,"agent":"engine","message":"Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.","time":1791610877933,"timeIso":"2026-10-10T05:41:17.933Z","changes":3,"change":895,"files":["worker/project/http.ts","worker/project/test/unseen.test.ts","worker/project/unseen.ts"],"originalMessage":"Messages and notes can't hold characters a reader can't see (abso issue 276): publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.","draft":null,"diff":[{"path":"worker/project/http.ts","added":18,"removed":0,"diff":"--- a/worker/project/http.ts\n+++ b/worker/project/http.ts\n@@ -1,6 +1,8 @@\n // The JSON routes of the contract (docs/v2-slice1.md), as a pure function of\n // the project calls, so they can be tested in Node without a Worker.\n+\n import type { EditBody, ProjectCalls, ProjectHistory } from \"./project-api.ts\";\n+import { unseenError } from \"./unseen.ts\";\n \n export interface Answer {\n \tstatus: number;\n@@ -429,6 +431,8 @@\n \t\t\tcase \"publish\": {\n \t\t\t\tconst message = (body as { message?: string })?.message;\n \t\t\t\tif (typeof message !== \"string\" || !message.trim()) return fail(400, \"publish needs {message} saying why\");\n+\t\t\t\tconst unseen = unseenError(\"the message\", message);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\t// asIs (#37): publish even with collided lines untouched since the sync, both sides kept.\n \t\t\t\treturn { status: 200, body: project.publish(agent, message, (body as { asIs?: unknown }).asIs === true) };\n \t\t\t}\n@@ -466,6 +470,8 @@\n \t\t\tcase \"land\": {\n \t\t\t\tconst message = (body as { message?: string })?.message;\n \t\t\t\tif (typeof message !== \"string\" || !message.trim()) return fail(400, \"land needs {message} saying why\");\n+\t\t\t\tconst unseen = unseenError(\"the message\", message);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\treturn { status: 200, body: project.land(agent, message) };\n \t\t\t}\n \t\t\tcase \"draft-sync\":\n@@ -491,6 +497,8 @@\n \t\t\t\tif (!history.amend) return fail(501, \"amend needs the engine\");\n \t\t\t\tconst message = (body as { message?: unknown } | undefined)?.message;\n \t\t\t\tif (typeof message !== \"string\" || !message.trim()) return fail(400, \"amend needs {message}\");\n+\t\t\t\tconst unseen = unseenError(\"the message\", message);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\treturn { status: 200, body: history.amend(agent, message) };\n \t\t\t}\n \t\t\t// Pluck (#27): take some versions of a named draft into shared.\n@@ -507,6 +515,8 @@\n \t\t\t\tif (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))\n \t\t\t\t\treturn fail(400, \"pluck needs {versions: [number]}\");\n \t\t\t\tif (typeof b.message !== \"string\" || !b.message.trim()) return fail(400, \"pluck needs {message} saying why\");\n+\t\t\t\tconst unseen = unseenError(\"the message\", b.message);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\treturn {\n \t\t\t\t\tstatus: 200,\n \t\t\t\t\tbody: history.pluck(agent, b.draft, b.versions as number[], b.message, b.withDependencies === true),\n@@ -520,6 +530,8 @@\n \t\t\t\tif (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))\n \t\t\t\t\treturn fail(400, \"drop needs {versions: [number], message}\");\n \t\t\t\tif (typeof b.message !== \"string\" || !b.message.trim()) return fail(400, \"drop needs {message} saying why\");\n+\t\t\t\tconst unseen = unseenError(\"the message\", b.message);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\treturn { status: 200, body: history.drop(agent, b.versions as number[], b.message, b.withDependents === true) };\n \t\t\t}\n \t\t\t// Announcements, and news without an edit.\n@@ -537,6 +549,8 @@\n \t\t\t\tif (!history.note || !history.closeNote) return fail(501, `${op} needs the engine`);\n \t\t\t\tconst b = (body ?? {}) as Record<string, unknown>;\n \t\t\t\tif (op === \"note-close\") return { status: 200, body: history.closeNote(agent, b.id as number, b.how) };\n+\t\t\t\tconst unseen = unseenError(\"the note\", b.text);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\treturn { status: 200, body: history.note(agent, b) };\n \t\t\t}\n \t\t\tcase \"announce\":\n@@ -546,6 +560,8 @@\n \t\t\t\tif (op === \"news\") return { status: 200, body: history.news(agent) };\n \t\t\t\tconst b = (body ?? {}) as { text?: unknown; to?: unknown };\n \t\t\t\tif (typeof b.text !== \"string\" || !b.text.trim()) return fail(400, \"announce needs {text}\");\n+\t\t\t\tconst unseen = unseenError(\"the text\", b.text);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\tif (b.to !== undefined && (!Array.isArray(b.to) || !b.to.every((a) => typeof a === \"string\")))\n \t\t\t\t\treturn fail(400, \"to must be a list of agent names\");\n \t\t\t\treturn { status: 200, body: history.announce(agent, b.text, b.to as string[] | undefined, how) };\n@@ -557,6 +573,8 @@\n \t\t\t\tconst b = (body ?? {}) as { text?: unknown; files?: unknown; issue?: unknown; done?: unknown };\n \t\t\t\tif (b.text !== null && (typeof b.text !== \"string\" || !b.text.trim()))\n \t\t\t\t\treturn fail(400, \"starting needs {text}, or {text: null} to take it back\");\n+\t\t\t\tconst unseen = unseenError(\"the note\", b.text);\n+\t\t\t\tif (unseen) return fail(400, unseen);\n \t\t\t\tif (b.files !== undefined && (!Array.isArray(b.files) || !b.files.every((f) => typeof f === \"string\")))\n \t\t\t\t\treturn fail(400, \"files must be a list of paths\");\n \t\t\t\t// issue (#54): the issue the note works on; done: a take-back because the work is finished, closing it."},{"path":"worker/project/test/unseen.test.ts","added":52,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/unseen.test.ts\n@@ -0,0 +1,52 @@\n+// Text the engine keeps and prints can't hold characters a reader can't see\n+// (abso issue 276): a version message with an escape sequence would run in\n+// every terminal that shows `abso log` or news.\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { answer } from \"../http.ts\";\n+import type { ProjectCalls } from \"../project-api.ts\";\n+import { unseenIn } from \"../unseen.ts\";\n+\n+const ESC = String.fromCharCode(0x1b);\n+const BEL = String.fromCharCode(0x07);\n+const CSI = String.fromCharCode(0x9b);\n+const RLO = String.fromCharCode(0x202e);\n+const CR = String.fromCharCode(0x0d);\n+\n+test(\"unseenIn: ESC, C1, BEL and bidi overrides are found; newline, tab and CRLF pass\", () => {\n+\tassert.equal(unseenIn(`Fix the parser\\n\\nDetails\\twith a tab${CR}\\nand CRLF.`), null);\n+\tassert.equal(unseenIn(`ok ${ESC}]52;c;aGk=${BEL}`), \"a control character at character 4\");\n+\tassert.equal(unseenIn(`${CSI}31m`), \"a control character at character 1\");\n+\tassert.equal(unseenIn(`a${CR}b`), \"a control character at character 2\");\n+\tassert.match(unseenIn(`abc${RLO}def`)!, /bidirectional embedding or override/);\n+\tassert.equal(unseenIn(`emoji 🎉 counts as one character ${ESC}`), \"a control character at character 33\");\n+});\n+\n+test(\"publish, amend, land, starting notes and announcements refuse unseen characters before the engine sees them\", () => {\n+\t// A stand-in for the engine: it records each call that gets through.\n+\tconst calls: string[] = [];\n+\tconst project = new Proxy({} as ProjectCalls, {\n+\t\tget:\n+\t\t\t(_, name) =>\n+\t\t\t(...args: unknown[]) => {\n+\t\t\t\tif (name === \"exists\") return true;\n+\t\t\t\tcalls.push(`${String(name)} ${JSON.stringify(args[1])}`);\n+\t\t\t\treturn { ok: true };\n+\t\t\t},\n+\t});\n+\tconst osc8 = `Fix ${ESC}]8;;https://example.invalid${BEL}here${ESC}]8;;${BEL}`;\n+\tconst refused = answer(project, \"publish\", \"ann\", { message: osc8 });\n+\tassert.equal(refused.status, 400);\n+\tassert.match(JSON.stringify(refused.body), /the message holds a control character at character 5/);\n+\tassert.equal(answer(project, \"amend\", \"ann\", { message: `Two ${ESC}[2J` }).status, 400);\n+\tassert.equal(answer(project, \"land\", \"ann\", { message: `Land ${CSI}1m` }).status, 400);\n+\tassert.equal(answer(project, \"starting\", \"ann\", { text: `on ${RLO}this` }).status, 400);\n+\tassert.equal(answer(project, \"announce\", \"ann\", { text: `hi ${BEL}` }).status, 400);\n+\tassert.deepEqual(calls, [], \"none reached the engine\");\n+\n+\tconst windows = `Two${CR}\\n${CR}\\nWritten on Windows.`;\n+\tassert.equal(answer(project, \"publish\", \"ann\", { message: windows }).status, 200);\n+\tassert.equal(answer(project, \"starting\", \"ann\", { text: \"on the parser\" }).status, 200);\n+\tassert.deepEqual(calls, [`publish ${JSON.stringify(windows)}`, 'starting \"on the parser\"']);\n+});"},{"path":"worker/project/unseen.ts","added":41,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/unseen.ts\n@@ -0,0 +1,41 @@\n+// Characters a reader can't see, refused in text the engine keeps and prints\n+// (abso issue 276): version messages, starting notes, line notes and\n+// announcements. In a terminal, ESC and C1 start escape sequences that can\n+// set the clipboard or draw a fake link, so `abso log` and news must never\n+// carry them. The same list as the website's announcements and Issues.\n+\n+const UNSEEN: [number, number, string][] = [\n+\t[0x00, 0x08, \"a control character\"],\n+\t[0x0b, 0x1f, \"a control character\"],\n+\t[0x7f, 0x9f, \"a control character\"],\n+\t[0x180e, 0x180e, \"the Mongolian vowel separator (U+180E)\"],\n+\t[0x200b, 0x200f, \"a zero-width or direction mark (U+200B-200F)\"],\n+\t[0x2028, 0x2029, \"a line or paragraph separator (U+2028-2029)\"],\n+\t[0x202a, 0x202e, \"a bidirectional embedding or override (U+202A-202E)\"],\n+\t[0x2060, 0x2064, \"an invisible joiner or operator (U+2060-2064)\"],\n+\t[0x2066, 0x2069, \"a bidirectional isolate (U+2066-2069)\"],\n+\t[0xfe00, 0xfe0f, \"a variation selector (U+FE00-FE0F)\"],\n+\t[0xfeff, 0xfeff, \"a byte order mark (U+FEFF)\"],\n+\t[0xe0000, 0xe007f, \"a tag character (U+E0000-E007F)\"],\n+\t[0xe0100, 0xe01ef, \"a variation selector (U+E0100-E01EF)\"],\n+];\n+\n+/**\n+ * The first character in `text` a reader can't see, as \"<what> at character N\", or null.\n+ * \\n and \\t pass, and so does \\r before \\n, since a message file written on Windows ends its lines that way.\n+ */\n+export function unseenIn(text: string): string | null {\n+\tfor (const [i, ch] of [...text].entries()) {\n+\t\tconst c = ch.codePointAt(0)!;\n+\t\tif (c === 0x0d && text[i + 1] === \"\\n\") continue;\n+\t\tconst hit = UNSEEN.find(([lo, hi]) => c >= lo && c <= hi);\n+\t\tif (hit) return `${hit[2]} at character ${i + 1}`;\n+\t}\n+\treturn null;\n+}\n+\n+/** Why `text`, named `what` (\"the message\"), can't be kept, or null. */\n+export function unseenError(what: string, text: unknown): string | null {\n+\tconst hit = typeof text === \"string\" ? unseenIn(text) : null;\n+\treturn hit === null ? null : `${what} holds ${hit}, which a reader can't see; take it out`;\n+}"}],"ci":null}