Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
gate1: read end tags like start tags, and give blocks their element offsets (#834)
nyblnet8c6400c1ae66
diff --git a/home/fixtures/gate1/README.md b/home/fixtures/gate1/README.mdindex 6b10c1c9..2d30d8ce 100644--- a/home/fixtures/gate1/README.md+++ b/home/fixtures/gate1/README.md@@ -56,6 +56,20 @@ Two parsing rules the reference got wrong once, so state them exactly:separator after it. A leading `=` is part of a name. Names fold ASCII-only,and the FIRST of duplicate names wins. A `<script>` tag with a duplicateattribute or a `/` is refused outright, because Bento writes neither.+- **Walk tags in document order, never search.** One walk, tag by tag, as the+ tokenizer meets them, feeds both the block list and the markup rules. A tag+ name runs to whitespace, `/` or `>`, so `<meta<style>` is ONE tag, and any+ name outside `[a-z][a-z0-9-]*` is refused. `script`, `style`, `textarea` and+ `title` hold text up to their real end tag: `</name` followed by whitespace,+ `/` or `>`. `<!-->` and `<!--->` are whole comments; `</>` is ignored.+- **Read END tags like start tags.** The tokenizer parses attributes in end tags,+ quoted values included, so `</p a="><b c='">` ends at its second `>`.+ Skipping to the first `>` hides the script after it. An end tag carrying any+ attribute, or an odd name, is refused, because Bento writes neither.+- **Offsets for splicing.** Each block carries `tagStart` (its start tag's `<`)+ and `end` (just past its end tag's `>`), from the same walk. A host that+ replaces an element splices `html.slice(tagStart, end)` and never finds a+ boundary itself.- **Fold case in ASCII only, never with a length-changing fold.** `toLowerCase()`turns `İ` into two UTF-16 units. Searching a folded copy while slicing theoriginal then drifts: a genuine Turkish document reads as unknown, and a run@@ -93,7 +107,9 @@ differently:- unquoted and single-quoted attributes;- `</script >`;- tabs and newlines inside a tag;-- a script inside a comment, `<textarea>`, `<title>` or `<style>`.+- a script inside a comment, `<textarea>`, `<title>` or `<style>`;+- glued tags (`<meta<style>`), empty comments, and false end tags (`</stylex>`);+- attributes, quoted `>` included, on an end tag.Your scanner must agree on every one of them.diff --git a/home/fixtures/gate1/expected.json b/home/fixtures/gate1/expected.jsonindex f66105ec..229b0f60 100644--- a/home/fixtures/gate1/expected.json+++ b/home/fixtures/gate1/expected.json@@ -265,6 +265,32 @@"release": "1.0.0","why": "\"<!-->\" and \"<!--->\" end at once: nothing after them is swallowed"},+ {+ "case": "served/endtag-quoted-gt.html",+ "verdict": "unknown",+ "why": "the end tag ends at its second \">\": the script after it is real and runs"+ },+ {+ "case": "served/endtag-attribute.html",+ "verdict": "unknown",+ "why": "an end tag carrying attributes: a browser drops them, but they move where the tag ends, and Bento writes none"+ },+ {+ "case": "served/endtag-on-pinned-script.html",+ "verdict": "unknown",+ "why": "an attribute on a pinned script's END tag: the block text is unchanged, and still refused"+ },+ {+ "case": "served/endtag-glued-name.html",+ "verdict": "unknown",+ "why": "an end tag named \"p<b\""+ },+ {+ "case": "served/endtag-empty.html",+ "verdict": "genuine",+ "release": "1.0.0",+ "why": "\"</>\" is ignored entirely: nothing after it is swallowed"+ },{"case": "served/empty-comment-in-paragraph.html","verdict": "genuine",diff --git a/home/fixtures/gate1/history.json b/home/fixtures/gate1/history.jsonindex 99c860fc..056e852b 100644--- a/home/fixtures/gate1/history.json+++ b/home/fixtures/gate1/history.json@@ -1,4 +1,4 @@{"payload": "{\"app\":\"bento-test\",\"v\":1,\"releases\":[{\"version\":\"1.2.0\",\"sha256\":\"598357b6211c04c75c86269aae84316057f1597b2001ddd8e8eae702cd731e0e\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"abb521c5dc2e7c9f4647381e938c74eb31a56068e136306ba23ae97f1605495d\",\"bento-rt-css\":\"2532e0b11a121cd38d3512d7f9301ccbb096b0be3c3290ff82d489dbe92a8d51\",\"loader\":\"aab97d902053b9246e94acccfba8407f4541ce91c439a0f52bc11f7f6bfc969c\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-qrl9kCBTuSRulKzM+6hAf0VBzpHEOaD1K8Eff2v8lpw=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"1.1.0\",\"sha256\":\"81ccd6107f33e3c1f65b8db8641937b20b46eb06681f9cb4958b3279d442b713\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e\",\"bento-rt-css\":\"b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457\",\"loader\":\"0c6558e59507fd53a98f060f9f5d4811b07b2e6fb4e0958fe538616a65cc1104\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-DGVY5ZUH/VOpjwYPn11IEbB7Lm+04JWP5ThhamXMEQQ=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"1.0.0\",\"sha256\":\"3f8cccc7ca6e790ec98be5595f19efe5bccb8059cba2edb2578d4a848366329d\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"89e0c5df6f7582ecdb6bc0afe889ee737e75d3c2c6c2fef9e71f2bc9d04a382e\",\"bento-rt-css\":\"b5f92bde69f3b5ce4b30d75e962f29a12d13eb551394bcd1bbd25d264014c457\",\"loader\":\"ada4c25d7a02b009b6bf2e056aa27c8760dfdcfb8150ef4f1f721f514bc4984a\",\"remover\":\"960226d430d9398a9e8b7400abf45c0da03797448ac4fbd7f7db2faaa2022659\"},\"scriptSrc\":[\"sha256-raTCXXoCsAm2vy4FaqJ8h2Df3PuBUO9PH3IfUUvEmEo=\",\"sha256-lgIm1DDZOYqei3QAq/RcDaA3l0SKxPvX99svqqICJlk=\"]}},{\"version\":\"0.9.0\",\"sha256\":\"c6a213a8cfa3d0e8d63b2a4f03a96f92acb0c2e1ec51b3f51a8a33f2cc0fab47\",\"at\":\"2026-10-21T00:00:00.000Z\",\"pins\":{\"v\":1,\"blocks\":{\"bento-rt\":\"831a646979271eedbf7f4df42a960f775eebff3d5a5ec459cc0341abeea8a9eb\",\"bento-rt-css\":\"bac24c27ae5dd952258247f6a7b487ec9cc868d862c21fe6dc4e5ec912958f5d\",\"loader\":\"2789e72054aae1988eb42361d396eeda9d4f29046b49c9c9b39b8415b26d24f7\",\"remover\":null},\"scriptSrc\":[\"sha256-J4nnIFSq4ZiOtCNh05bu2p1PKQRrScnJs5uEFbJtJPc=\"]}}]}",- "sig": "n8omewr7M5y01+na7mr9N0Zt7IF8kGHfZ5LUTA3aVA6ZZBRMcme++gVUggysFrSTxePh/Z8YmqHZP/Jmy2ZBbg=="+ "sig": "S8k1V7Z/cb8vU7M699hcIv8uBSTct+6APmKj7s6RXmdjIZ1cmEiZ+zpUBrW4pwqvv6JkCMdtR3eWDfv1uZ9ilw=="}diff --git a/home/fixtures/gate1/served/endtag-attribute.html b/home/fixtures/gate1/served/endtag-attribute.htmlnew file mode 100644index 00000000..8d6fa00a--- /dev/null+++ b/home/fixtures/gate1/served/endtag-attribute.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en"><head>+<meta charset="UTF-8">+<title>A deck</title>+<style>body{margin:0}</style>+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>+</head><body>+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>+<script>load1()</script>+<p>x</p class="x"></body></html>diff --git a/home/fixtures/gate1/served/endtag-empty.html b/home/fixtures/gate1/served/endtag-empty.htmlnew file mode 100644index 00000000..bc7520f5--- /dev/null+++ b/home/fixtures/gate1/served/endtag-empty.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en"><head>+<meta charset="UTF-8">+<title>A deck</title>+<style>body{margin:0}</style>+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>+</head><body>+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>+<script>load1()</script>+<p>x</>y</p></body></html>diff --git a/home/fixtures/gate1/served/endtag-glued-name.html b/home/fixtures/gate1/served/endtag-glued-name.htmlnew file mode 100644index 00000000..0cdd9953--- /dev/null+++ b/home/fixtures/gate1/served/endtag-glued-name.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en"><head>+<meta charset="UTF-8">+<title>A deck</title>+<style>body{margin:0}</style>+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>+</head><body>+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>+<script>load1()</script>+<p>x</p<b></body></html>diff --git a/home/fixtures/gate1/served/endtag-on-pinned-script.html b/home/fixtures/gate1/served/endtag-on-pinned-script.htmlnew file mode 100644index 00000000..883498f7--- /dev/null+++ b/home/fixtures/gate1/served/endtag-on-pinned-script.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en"><head>+<meta charset="UTF-8">+<title>A deck</title>+<style>body{margin:0}</style>+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script a=">">+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>+</head><body>+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>+<script>load1()</script>+</body></html>diff --git a/home/fixtures/gate1/served/endtag-quoted-gt.html b/home/fixtures/gate1/served/endtag-quoted-gt.htmlnew file mode 100644index 00000000..7503fbf8--- /dev/null+++ b/home/fixtures/gate1/served/endtag-quoted-gt.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en"><head>+<meta charset="UTF-8">+<title>A deck</title>+<style>body{margin:0}</style>+<script type="application/bento+json" id="bento-doc">{"format":"bento/test","title":"A deck"}</script>+<script type="bento/deflate-b86" id="bento-rt-css" data-len="4">CSS1</script>+<script type="bento/deflate-b86" id="bento-rt" data-len="3">RT1</script>+</head><body>+<div data-bento-preview="1"><p>Page one</p></div><script data-bento-preview="1">(function(){var a=document.querySelectorAll('[data-bento-preview]');for(var i=0;i<a.length;i++)a[i].remove()})()</script>+<script>load1()</script>+</p a="><b c='">'<script>window.pwned=5</script>'></body></html>diff --git a/home/fixtures/gate1/test-public-key.json b/home/fixtures/gate1/test-public-key.jsonindex 68f38af6..b952bd14 100644--- a/home/fixtures/gate1/test-public-key.json+++ b/home/fixtures/gate1/test-public-key.json@@ -1,6 +1,6 @@{"kty": "EC",- "x": "8UDzn4Mgpqbtk4-ODYShq9ldn96SrxUkpjN9CTy4q-Y",- "y": "CvhD30oTPWQEGe9pYwmZXzBYIGEFAnONUjz1kDO7URo",+ "x": "E2br8l9bB7RRpQ3E3bfELJ-nSxgKICKbVF2I2Qe1yKQ",+ "y": "RHstg4XCbJXI0L6k9e5l_O7SKyspC5kAZia9slsCPf0","crv": "P-256"}diff --git a/kernel/src/gate1.ts b/kernel/src/gate1.tsindex 9fa60ba5..2ede88df 100644--- a/kernel/src/gate1.ts+++ b/kernel/src/gate1.ts@@ -40,11 +40,16 @@ export interface History { app: string; v: 1; releases: HistoryEntry[] }export interface Block {tag: 'script' | 'style'+ /** the whole start tag, exactly as written: html.slice(tagStart, start) */attrs: string- /** the raw text, which ends at the first `</script` / `</style` in any case, as the HTML tokenizer ends it */+ /** the raw text, which ends at the element's real end tag, as the HTML tokenizer ends it */text: string+ /** offset of the start tag's "<" */+ tagStart: number/** offset of the text's first character in the file */start: number+ /** offset just past the end tag's ">", as the tokenizer ends it (quoted attribute values and all) */+ end: numbertype: string | nullid: string | nullsrc: string | null@@ -79,11 +84,27 @@ export const asciiLower = (s: string): string => s.replace(/[A-Z]/g, (c) => Striconst WS = (c: string | undefined) => c === '\t' || c === '\n' || c === '\f' || c === '\r' || c === ' 'export function parseStartTag(html: string, i: number): StartTag | null {- const m = /^<([a-zA-Z][^\t\n\f\r />]*)/.exec(html.slice(i, i + 256))+ return html[i] === '<' ? readTag(html, i + 1) : null+}++/**+ * An END tag, read exactly like a start tag. The tokenizer parses attributes in+ * end tags too, quoted values included, and then drops them, so+ * `</p a="><b c='">` ends at its SECOND ">". Skipping an end tag to its first ">"+ * instead read `<b c='">'<script>` as one tag and missed the script after it+ * (both engines ran it). null if `i` isn't "</" and a letter, or it's unterminated.+ */+export function parseEndTag(html: string, i: number): StartTag | null {+ return html[i] === '<' && html[i + 1] === '/' ? readTag(html, i + 2) : null+}++/** A tag's name and attributes, from its name's first character. */+function readTag(html: string, at: number): StartTag | null {+ const m = /^([a-zA-Z][^\t\n\f\r />]*)/.exec(html.slice(at, at + 256))if (!m) return nullconst attrs = new Map<string, string>()let duplicate = false, slash = false- let j = i + m[0].length+ let j = at + m[0].lengthwhile (j < html.length) {const c = html[j]if (WS(c)) { j++; continue }@@ -161,8 +182,18 @@ function walk(html: string): Walk {if (end < 0) { problems.push('an unterminated comment'); break }i = end + 3; continue}+ if (html[i + 1] === '/' && /[a-zA-Z]/.test(html[i + 2] ?? '')) {+ // an end tag: tokenized with the start tag's attribute rules (see parseEndTag)+ const et = parseEndTag(html, i)+ if (!et) { problems.push('an unterminated end tag'); break }+ if (!TAG_NAME.test(et.name)) problems.push(`an end tag named ${JSON.stringify(et.name)}`)+ // a browser drops them, but they move where the tag ends: Bento writes none+ if (et.attrs.size) problems.push(`an end tag </${et.name}> carrying attributes`)+ i = et.end; continue+ }+ if (html.startsWith('</>', i)) { i += 3; continue } // ignored entirelyif (html[i + 1] === '/' || html[i + 1] === '!' || html[i + 1] === '?') {- // an end tag, a doctype or a bogus comment: no attributes a browser acts on+ // a doctype or a bogus comment: it ends at the first ">", quotes or notconst end = html.indexOf('>', i + 2)if (end < 0) { problems.push('an unterminated tag'); break }i = end + 1; continue@@ -185,13 +216,16 @@ function walk(html: string): Walk {// would count it: refuse, so every host's scanner reaches the same verdictif (name !== 'script' && lower.slice(tag.end, close).includes('<script')) problems.push(`a <${name}> holds a <script>`)if (name === 'textarea' || name === 'title') { i = close; continue }+ const et = parseEndTag(html, close)+ if (!et) { problems.push(`an unterminated </${name}>`); break }const get = (n: string) => tag.attrs.has(n) ? tag.attrs.get(n)! : nullblocks.push({- tag: name as 'script' | 'style', attrs: html.slice(i, tag.end), text: html.slice(tag.end, close), start: tag.end,+ tag: name as 'script' | 'style', attrs: html.slice(i, tag.end), text: html.slice(tag.end, close),+ tagStart: i, start: tag.end, end: et.end,type: get('type'), id: get('id'), src: get('src'), preview: tag.attrs.has('data-bento-preview'),duplicate: tag.duplicate, slash: tag.slash,})- i = close; continue // its end tag is skipped as an end tag+ i = close; continue // its end tag is judged next, as an end tag}i = tag.end}diff --git a/scripts/gen-gate1-corpus.ts b/scripts/gen-gate1-corpus.tsindex f82cbf28..aa181ff1 100644--- a/scripts/gen-gate1-corpus.ts+++ b/scripts/gen-gate1-corpus.ts@@ -122,6 +122,14 @@ const served: Served[] = [{ name: 'a-glued-comment', html: body('<a<!-- x -->'), verdict: 'unknown', why: 'a start tag named "a<!--"' },{ name: 'empty-comment-then-script', html: body(`<!--><${S}>window.pwned=4</${S}>`), verdict: 'unknown', why: '"<!-->" is a whole comment: the script after it is real' },{ name: 'empty-comment-alone', html: body('<!--><!---><p>after</p>'), verdict: 'genuine', release: '1.0.0', why: '"<!-->" and "<!--->" end at once: nothing after them is swallowed' },+ // END tags are tokenized like start tags, quoted attribute values and all: in+ // `</p a="><b c='">` the tag ends at the SECOND ">", so the script after it runs.+ // Skipping an end tag to its first ">" read `<b c='">'<script>` as one tag.+ { name: 'endtag-quoted-gt', html: body(`</p a="><b c='">'<${S}>window.pwned=5</${S}>'>`), verdict: 'unknown', why: 'the end tag ends at its second ">": the script after it is real and runs' },+ { name: 'endtag-attribute', html: body('<p>x</p class="x">'), verdict: 'unknown', why: 'an end tag carrying attributes: a browser drops them, but they move where the tag ends, and Bento writes none' },+ { name: 'endtag-on-pinned-script', html: g.replace(/<\/script>/, '</script a=">">'), verdict: 'unknown', why: 'an attribute on a pinned script\'s END tag: the block text is unchanged, and still refused' },+ { name: 'endtag-glued-name', html: body('<p>x</p<b>'), verdict: 'unknown', why: 'an end tag named "p<b"' },+ { name: 'endtag-empty', html: body('<p>x</>y</p>'), verdict: 'genuine', release: '1.0.0', why: '"</>" is ignored entirely: nothing after it is swallowed' },// the browser's reading must WIN in the genuine direction too (home-desktop):// a walk that ends raw text at any "</name", or doesn't know "<!-->", would// wrongly refuse these, and no unknown row could telldiff --git a/scripts/test-gate1-oracle.mjs b/scripts/test-gate1-oracle.mjsindex 2ada9fc1..73ec455c 100644--- a/scripts/test-gate1-oracle.mjs+++ b/scripts/test-gate1-oracle.mjs@@ -98,6 +98,13 @@ function mutant(r, n) {`<a<!--${candidate}-->`, `<!-->${candidate}`, `<!--->${candidate}`])h = h.replace(pick(['</head>', '</body>', '<meta charset="UTF-8">']), (m) => m === '<meta charset="UTF-8">' ? glue + ' ' + m : glue + m)}+ // quoted attributes in END tags: the tokenizer reads them, so a ">" inside the+ // quotes doesn't end the tag, and what a first-">" skip reads as a tag is text+ if (r() < 0.15) {+ const t = pick(['p', 'div', 'span', 'b'])+ const shut = pick([`</${t} a="><b c='">'${candidate}'>`, `</${t} x='><i y="'>"${candidate}">`, `</${t}${sep()}a=${q('>')}>${candidate}`])+ h = h.replace(pick(['</body>', '</head>']), (m) => shut + m)+ }// the loader's own text behind a src=: the browser runs the src and ignores itif (r() < 0.1) h = h.replace(`<${S}>${LOADER}`, `<${S}${sep()}src=${q('data:text/javascript,' + encodeURIComponent(body))}>${LOADER}`)// or edit a real block's tag the ways scanners splitdiff --git a/scripts/test-gate1.ts b/scripts/test-gate1.tsindex 90fee609..698c3b59 100644--- a/scripts/test-gate1.ts+++ b/scripts/test-gate1.ts@@ -19,7 +19,7 @@ import { readFileSync } from 'node:fs'import { join, dirname } from 'node:path'import { fileURLToPath } from 'node:url'import { createPublicKey, verify } from 'node:crypto'-import { verifyServed, verifyStrict, acceptHistory, hostPolicy, type History, type StrictExpected } from '../kernel/src/gate1.ts'+import { verifyServed, verifyStrict, acceptHistory, hostPolicy, scanBlocks, parseStartTag, parseEndTag, type History, type StrictExpected } from '../kernel/src/gate1.ts'let failures = 0let checks = 0@@ -56,6 +56,24 @@ for (const row of E.served) {}console.log('\nambiguous: two entries matching every block is UNKNOWN, never "the first"')+console.log('\nblock offsets: a host can splice a whole element without a second parser (home-webext, W2)')+{+ let blocks = 0, bad: string[] = []+ for (const row of E.served) {+ const html = read(row.case)+ let scanned+ try { scanned = scanBlocks(html) } catch { continue }+ for (const b of scanned) {+ blocks+++ const open = html.slice(b.tagStart, b.start), close = html.slice(b.start + b.text.length, b.end)+ const st = parseStartTag(html, b.tagStart), et = parseEndTag(html, b.start + b.text.length)+ if (open !== b.attrs || st?.end !== b.start || st?.name !== b.tag) bad.push(`${row.case} @${b.tagStart}: open tag`)+ if (et?.end !== b.end || et?.name !== b.tag || !close.endsWith('>')) bad.push(`${row.case} @${b.tagStart}: close tag ${JSON.stringify(close)}`)+ }+ }+ ok(blocks > 100 && bad.length === 0, `on every served row (${blocks} blocks): html.slice(tagStart, start) is the exact start tag and html.slice(start + text.length, end) the exact end tag${bad.length ? ' — ' + bad.slice(0, 3).join('; ') : ''}`)+}+for (const row of E.ambiguous) ok((await verifyServed(read(row.case), row.history)).verdict === row.verdict, `${row.case.replace('served/', '')} under its own history: ${row.verdict} (${row.why})`)console.log('\nstrict (file://): both genuine saves pass, all 16 tampers refuse')