mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 14:45:44 +01:00
Answer stability round 1: 0 🔴, 5 🟡 (0 misread); each fact list now tells its refusal apart, the HTML table pins the rule and escape, the duplicate proxy check dropped
This commit is contained in:
@@ -490,49 +490,49 @@ test('refuses a tag of three million attributes, past what one pattern over them
|
||||
})
|
||||
|
||||
const messages: readonly (readonly [string, readonly string[]])[] = [
|
||||
['<p>a<b>b</b></p>\n', ['<b>', 'found "<b>b</b></p>\\n"']],
|
||||
['<p>a > b</p>\n', ['& as &', '< as <', 'found "> b</p>\\n"']],
|
||||
['<p><a href="a"b">a</a></p>\n', ['<a>', '& as &', '" as "', 'found "b\\">a</a></p>\\n"']],
|
||||
['<p>&b</p>\n', ['& as &', '< as <', 'found "&b</p>\\n"']],
|
||||
['<pre><code>a&b</code></pre>\n', ['& as &', '< as <', 'found "&b</code></pre>\\n"']],
|
||||
['<p>a </p>\n', ['& as &', '< as <', 'found " </p>\\n"']],
|
||||
['<pre><code>a</code></pre\n', ['found "</code></pre\\n"']],
|
||||
['<pre><code class="hljs language-js">x</code></pre>\n', ['<code>', 'found "<code class=\\"hljs langua"…']],
|
||||
['<ul>\n<li>a</ul>\n', ['< as <', 'found "</ul>\\n"']],
|
||||
['<ul>\n<li>a<b>b</b></li>\n</ul>\n', ['<b>', 'found "<b>b</b></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>if a < b</li>\n</ul>\n', ['< as <', 'found "< b</li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>see <a href="https://x.test/?a=1&b=2">x</a></li>\n</ul>\n', ['<a>', '& as &', '" as "', 'found "&b=2\\">x</a></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li><p>a</p><strong>x</strong></li>\n</ul>\n', ['found "<strong>x</strong></li>\\n"…']],
|
||||
['<ul>\n<li>Bolt<ul>\n<li>a</li>\n</ul></li>\n</ul>\n', ['found "<ul>\\n<li>a</li>\\n</ul></l"…']],
|
||||
['<ul>\n<li>a<li>b</li>\n</ul>\n', ['found "<li>b</li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>a\n<li>b</li>\n</ul>\n', ['found "<li>b</li>\\n</ul>\\n"']],
|
||||
['<p><strong><b>x</b></strong></p>\n', ['<b>', 'found "<b>x</b></strong></p>\\n"']],
|
||||
['<p><strong><br>x</strong></p>\n', ['<br>', 'found "<br>x</strong></p>\\n"']],
|
||||
['<p><em></em></p>\n', ['found "</em></p>\\n"']],
|
||||
['<p><strong><a href="https://x.test/?a=1&b=2">x</a></strong></p>\n', ['<a>', '& as &', '" as "', 'found "&b=2\\">x</a></strong></p>"…']],
|
||||
[`<p>a</p>\n${carry('div', panel, '<p>Check the <b>collation</b>.</p>')}\n`, ['to change the node, edit its ADF and write the HTML again', 'found "<b>collation</b>.</p></d"…']],
|
||||
['<p><span>a</span></p>\n', ['found "<span>a</span></p>\\n"']],
|
||||
['<div class="adf-carry" data-adf="{ "type":"x"}"></div>\n', ['found "{ "type":""…']],
|
||||
[`${documentCarry}\n<hr>\n`, ['found "\\n<hr>\\n"']],
|
||||
[`<hr>\n${documentCarry}\n`, ['found "<div class=\\"adf-carry\\" d"…']],
|
||||
['<ul>\n<li><p>Bolt</p></li>\n</ul>\n', ['found "<p>Bolt</p></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li><p></p></li>\n</ul>\n', ['found "<p></p></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>\n<p data-local-id="x"></p>\n</li>\n</ul>\n', ['found "<p data-local-id=\\"x\\"></p"…']],
|
||||
['<p><img src="a">b</p>\n', ['found "b</p>\\n"']],
|
||||
['<p><img src="a" alt=""></p>\n', ['found "<img src=\\"a\\" alt=\\"\\"></p>"…']],
|
||||
['<ol start="03">\n<li>a</li>\n</ol>\n', ['found "03\\">\\n<li>a</li>\\n</ol>\\n"']],
|
||||
['<p class="x">a</p>\n', ['<p>', 'takes no class attribute']],
|
||||
['<p data-color="x">a</p>\n', ['<p>', 'takes no data-color attribute']],
|
||||
['<ol data-local-id="x" start="2">\n<li>a</li>\n</ol>\n', ['<ol>', 'found start after data-local-id']],
|
||||
['<ol start="2" start="3">\n<li>a</li>\n</ol>\n', ['<ol>', 'found start after start']],
|
||||
['<ol start="2" data-bogus="1" start="3">\n<li>a</li>\n</ol>\n', ['<ol>', 'takes no data-bogus attribute']],
|
||||
['<p>a<b>b</b></p>\n', ['<b> as written here is no inline element of the dialect', 'found "<b>b</b></p>\\n"']],
|
||||
['<p>a > b</p>\n', ['text escapes & as &', '> as >', 'found "> b</p>\\n"']],
|
||||
['<p><a href="a"b">a</a></p>\n', ['<a> holds its attributes as name="value"', '" as "', 'found "b\\">a</a></p>\\n"']],
|
||||
['<p>&b</p>\n', ['text escapes & as &', 'found "&b</p>\\n"']],
|
||||
['<pre><code>a&b</code></pre>\n', ['text escapes & as &', 'found "&b</code></pre>\\n"']],
|
||||
['<p>a </p>\n', ['text escapes & as &', 'found " </p>\\n"']],
|
||||
['<pre><code>a</code></pre\n', ['a code block\'s text ends at </code></pre>', 'found "</code></pre\\n"']],
|
||||
['<pre><code class="hljs language-js">x</code></pre>\n', ['<code> as written here is no code element of the dialect', 'found "<code class=\\"hljs langua"…']],
|
||||
['<ul>\n<li>a</ul>\n', ['the line ends at </li>', '< as <', 'found "</ul>\\n"']],
|
||||
['<ul>\n<li>a<b>b</b></li>\n</ul>\n', ['<b> as written here is no inline element of the dialect', 'found "<b>b</b></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>if a < b</li>\n</ul>\n', ['the line ends at </li>', '< as <', 'found "< b</li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>see <a href="https://x.test/?a=1&b=2">x</a></li>\n</ul>\n', ['<a> holds its attributes as name="value"', '& as &', '" as "', 'found "&b=2\\">x</a></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li><p>a</p><strong>x</strong></li>\n</ul>\n', ['the line ends at </li>', 'found "<strong>x</strong></li>\\n"…']],
|
||||
['<ul>\n<li>Bolt<ul>\n<li>a</li>\n</ul></li>\n</ul>\n', ['the line ends at </li>', 'found "<ul>\\n<li>a</li>\\n</ul></l"…']],
|
||||
['<ul>\n<li>a<li>b</li>\n</ul>\n', ['the line ends at </li>', 'found "<li>b</li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>a\n<li>b</li>\n</ul>\n', ['the line ends at </li>', 'found "<li>b</li>\\n</ul>\\n"']],
|
||||
['<p><strong><b>x</b></strong></p>\n', ['<b> as written here is no mark element of the dialect', 'found "<b>x</b></strong></p>\\n"']],
|
||||
['<p><strong><br>x</strong></p>\n', ['<br> as written here is no mark element of the dialect', 'found "<br>x</strong></p>\\n"']],
|
||||
['<p><em></em></p>\n', ['a mark element holds text', 'found "</em></p>\\n"']],
|
||||
['<p><strong><a href="https://x.test/?a=1&b=2">x</a></strong></p>\n', ['<a> holds its attributes as name="value"', '& as &', '" as "', 'found "&b=2\\">x</a></strong></p>"…']],
|
||||
[`<p>a</p>\n${carry('div', panel, '<p>Check the <b>collation</b>.</p>')}\n`, ['a carry element shows what adfToHtml writes for its node', 'to change the node, edit its ADF and write the HTML again', 'found "<b>collation</b>.</p></d"…']],
|
||||
['<p><span>a</span></p>\n', ['a <span> of the dialect is a carry element', 'found "<span>a</span></p>\\n"']],
|
||||
['<div class="adf-carry" data-adf="{ "type":"x"}"></div>\n', ['a carry element spells its node\'s JSON canonically', 'found "{ "type":""…']],
|
||||
[`${documentCarry}\n<hr>\n`, ['a carry element holding the document stands alone', 'found "\\n<hr>\\n"']],
|
||||
[`<hr>\n${documentCarry}\n`, ['a carry element holding the document stands alone', 'found "<div class=\\"adf-carry\\" d"…']],
|
||||
['<ul>\n<li><p>Bolt</p></li>\n</ul>\n', ['an item\'s or cell\'s first paragraph holding content and no attribute stands bare on the line of the item\'s or cell\'s start tag', 'found "<p>Bolt</p></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li><p></p></li>\n</ul>\n', ['an item\'s or cell\'s first paragraph holding neither content nor an attribute stands on a line of its own', 'found "<p></p></li>\\n</ul>\\n"']],
|
||||
['<ul>\n<li>\n<p data-local-id="x"></p>\n</li>\n</ul>\n', ['an item\'s or cell\'s first paragraph holding an attribute stands as its <p> straight after the item\'s or cell\'s start tag', 'found "<p data-local-id=\\"x\\"></p"…']],
|
||||
['<p><img src="a">b</p>\n', ['an image stands alone in its paragraph as <img src="…" alt="…">', 'found "b</p>\\n"']],
|
||||
['<p><img src="a" alt=""></p>\n', ['an image stands alone in its paragraph as <img src="…" alt="…">', 'found "<img src=\\"a\\" alt=\\"\\"></p>"…']],
|
||||
['<ol start="03">\n<li>a</li>\n</ol>\n', ['an ordered list starts at an integer', 'found "03\\">\\n<li>a</li>\\n</ol>\\n"']],
|
||||
['<p class="x">a</p>\n', ['<p>', 'no class attribute']],
|
||||
['<p data-color="x">a</p>\n', ['<p>', 'no data-color attribute']],
|
||||
['<ol data-local-id="x" start="2">\n<li>a</li>\n</ol>\n', ['<ol> takes start once', 'found start after data-local-id']],
|
||||
['<ol start="2" start="3">\n<li>a</li>\n</ol>\n', ['<ol> takes start once', 'found start after start']],
|
||||
['<ol start="2" data-bogus="1" start="3">\n<li>a</li>\n</ol>\n', ['<ol>', 'no data-bogus attribute']],
|
||||
['<pre data-wrap="yes"><code>x</code></pre>\n', ['data-wrap', 'boolean']],
|
||||
['<p><span class="adf-emoji"></span></p>\n', ['<span class="adf-emoji">', 'found "</span></p>\\n"']],
|
||||
['<p><a class="adf-inline-card" href="https://example.com/">Spec</a></p>\n', ['<a class="adf-inline-card">', 'to change the card, change them together', 'found "Spec</a></p>\\n"']],
|
||||
[`<p><a class="adf-inline-card" href="https://example.org/plan" data-data="${planData}">Plan</a></p>\n`, ['<a class="adf-inline-card">', 'to change the card, change them together', 'found "Plan</a></p>\\n"']],
|
||||
['<p><time class="adf-date" datetime="2025-08-26" data-timestamp="1756080000000">x</time></p>\n', ['<time class="adf-date">', 'to change the date, change all three', 'found "x</time></p>\\n"']],
|
||||
['<p><span class="adf-emoji" data-size="big">a</span></p>\n', ['<span class="adf-emoji">', 'takes no data-size attribute']],
|
||||
['<p><span class="adf-status">a&b</span></p>\n', ['& as &', '< as <', 'found "&b</span></p>\\n"']],
|
||||
['<p><span class="adf-emoji"></span></p>\n', ['<span class="adf-emoji"> holds its text', 'found "</span></p>\\n"']],
|
||||
['<p><a class="adf-inline-card" href="https://example.com/">Spec</a></p>\n', ['<a class="adf-inline-card"> holds one URL', 'to change the card, change them together', 'found "Spec</a></p>\\n"']],
|
||||
[`<p><a class="adf-inline-card" href="https://example.org/plan" data-data="${planData}">Plan</a></p>\n`, ['<a class="adf-inline-card"> holds one URL', 'to change the card, change them together', 'found "Plan</a></p>\\n"']],
|
||||
['<p><time class="adf-date" datetime="2025-08-26" data-timestamp="1756080000000">x</time></p>\n', ['<time class="adf-date"> shows the day its data-timestamp names', 'to change the date, change all three', 'found "x</time></p>\\n"']],
|
||||
['<p><span class="adf-emoji" data-size="big">a</span></p>\n', ['<span class="adf-emoji">', 'no data-size attribute']],
|
||||
['<p><span class="adf-status">a&b</span></p>\n', ['text escapes & as &', 'found "&b</span></p>\\n"']],
|
||||
]
|
||||
|
||||
for (const [html, facts] of messages) test(`names what it found where reading stopped, a character no one sees as its escape: ${JSON.stringify(html)}`, () => names(htmlToAdf(html), ...facts))
|
||||
|
||||
Reference in New Issue
Block a user