WPT: 93,88% del corpus del tokenizer, e due difetti veri trovati subito
Il WPT vero non è agganciabile: i suoi test di parsing sono pagine che girano in testharness.js e vogliono DOMParser, createHTMLDocument e un event loop asincrono — cose che il motore non ha. Il corpus `html5lib-tests/tokenizer` è invece la sorgente da cui WPT genera quei test, e misurarlo dà un numero confrontabile invece di un'affermazione. - engine/src/bin/wpt.rs: legge i .test, esegue i casi, confronta i token, stampa percentuali per file e totale; `--min N` fa fallire la CI sotto soglia (93%) - engine/scripts/scarica-corpus.sh: rigenera il corpus (1,7 MB, nel repository perché la CI non deve dipendere dalla rete) Il corpus ha trovato subito due difetti: 1. **Il tokenizer si BLOCCAVA** su `<h/a='b'>`, `<a/\0>` e `<z/0 <>`: nel ciclo degli attributi, una `/` non seguita da `>` produceva un nome vuoto e `j` non avanzava mai. Ora il carattere si scarta e si prosegue (e `<h/a='b'>` vale `<h a='b'>`, come dice la specifica). Un blocco, non un token sbagliato. 2. **Ogni `<!…>` diventava un doctype**, anche `<!>`, `<!ciao>`, `<! `, `<?…>`: doveva essere un **commento spurio**. Era il grosso dei fallimenti in test3. Più: entità HTML nominate complete (2231 voci generate da entities.json del WHATWG, forme legacy e multi-carattere comprese) e DOCTYPE con nome, PUBLIC/SYSTEM e segnalazione degli errori. Numeri: 48,42% al primo giro, 82,09% con le entità, 93,88% con commento spurio e doctype (6247 casi su 6654 eseguibili, 166 saltati). Restano fuori gli stati iniziali diversi da quello dei dati (RCDATA, CDATA, script, PLAINTEXT), lastStartTag e la serializzazione: dichiarati, non nascosti. Effetti collaterali utili: le entità complete migliorano ogni pagina reale con simboli tipografici; il commento spurio rende il parsing di `<![CDATA[` e delle dichiarazioni PHP-like meno sbagliato di prima.
This commit is contained in:
1 parent
36dbc691d9
commit
e2b238d424
28 files changed
+62302
-44
No files matched your search
+9
-2
@@ -71,6 +71,7 @@ gusci (Sailfish e desktop) ricostruiti sullo stesso motore.
|
||||
**Fuori ambito dichiarato:** multiplexing HTTP/2, `PUSH_PROMISE` e priorità; proxy SOCKS e PAC; invio di file (`input type=file`); sul telefono il servizio di rete resta nel processo, perché un'app sandboxata non avvia processi figli in modo affidabile. **Sul telefono** `fetch` e i cookie sono collegati: sessione di rete nel confine C (`engine_session_*`), documento creato con la sessione, richieste degli script eseguite dal guscio e consegnate al motore |
|
||||
| M2.8 Grid | `display:grid`, `grid-template-columns/rows` (`px`, `%`, `fr`, `auto`, `minmax`, `repeat`), `gap`, posizionamento automatico, `grid-column/row: span N`, `align-items` | **fatto** (casi 92–98): elementi con altezza automatica riempiono la riga (`stretch`), righe implicite dall'altezza del contenuto. **Fuori ambito dichiarato:** posizionamento esplicito (`grid-column: 2 / 4`), aree e linee con nome, `grid-auto-flow: column`, `justify-items`, ridistribuzione delle altezze su più righe con `span`, `auto-fill`/`auto-fit` (valgono una traccia) |
|
||||
| M2.9 Immagini | `max-width` applicato alle immagini sostituite, `height:auto` che segue il rapporto (attributi `width`/`height` o proporzione intrinseca), percentuali risolte sul **contenitore** e non sullo spazio disponibile | **fatto** (casi 99–100). Era il difetto che faceva uscire le copertine 1200×630 da una colonna da 700: la regola `img{max-width:100%;height:auto}` di quasi ogni tema veniva ignorata |
|
||||
| M2.12 Conformità | `src/bin/wpt.rs` sul corpus `html5lib-tests/tokenizer`, soglia 93% in CI; entità HTML nominate generate dal WHATWG (2231 voci); `DOCTYPE` con nome, `PUBLIC`/`SYSTEM` e segnalazione degli errori; commento spurio per `<!` e `<?` che non sono doctype | **fatto**: 93,88% (6247/6654). Il corpus ha trovato subito due difetti veri: il tokenizer **si bloccava** su `<h/a='b'>`, `<a/\0>`, `<z/0 <>` (ciclo senza avanzamento), e ogni `<!…>` diventava un doctype invece di un commento |
|
||||
| M2.10 Proprietà CSS | `font-style` (corsivo sintetico), `text-decoration` (sottolineato e barrato), `text-transform`, `letter-spacing`, `opacity`, `border-radius`, `min/max-height`, `min-width`, `overflow: hidden`, `background-image`, `linear-gradient`, `background-size` (`auto`/`cover`/`contain`/misura) e `background-repeat` (`repeat`, `repeat-x`, `repeat-y`, `no-repeat`); regole UA per link, `em`/`i`, `b`/`strong`, `s`/`del`; sfondo di `html`/`body` propagato alla tela | **fatto** (casi 101–107 e 113–116), con prove a pixel. Il ritaglio delle immagini ora **taglia** invece di schiacciare (`draw_image_clippata`), anche dentro `overflow: hidden`. **Fuori ambito:** bordi con raggio (si arrotondano sfondo e immagini, non il bordo spesso), `space`/`round` (valgono come `repeat`), `background-position`, gradienti non lineari |
|
||||
| M2.11 Selettori | `:where()`, `:is()`, `:not()`, `:root`, `:first-child`, `:last-child`, `:empty`, `:link`/`:any-link`, combinatore `>`; divisione dei selettori e dei composti consapevole delle parentesi | **fatto** (casi 108–112): senza `:where()` metà del CSS dei temi WordPress viene scartato. **Fuori ambito:** `:hover`/`:focus`/`:nth-child()`/`:has()` non corrispondono (documento fermo), `+` e `~` scartano la regola, pseudo-elementi |
|
||||
| M2.7 Compositor | tile, danni, scroll compositato, animazioni (`wgpu`) | da fare |
|
||||
@@ -117,8 +118,14 @@ Residui dichiarati dei formulari, con il costo stimato:
|
||||
| Menu a tendina a comparsa | motore: elenco disegnato con le opzioni e la voce evidenziata; gusci: apertura e scelta | **fatto** (caso 85) |
|
||||
| Invio del form (`action`, GET/POST, codifica dei campi) | motore + rete | **fatto**: `invio.rs`, GET con query, POST `urlencoded`/`multipart`/`text/plain`, `preventDefault` rispettato; mancano i file |
|
||||
|
||||
Voci trasferite da M1: bidi (fatto, vedi M2.1) e harness WPT con soglia ≥ 90 % sul
|
||||
parsing (ancora da agganciare: richiede il corpus esterno).
|
||||
Voci trasferite da M1: bidi (fatto, vedi M2.1) e harness WPT **agganciato** (M2.12):
|
||||
`engine/src/bin/wpt.rs` esegue il corpus `html5lib-tests/tokenizer` — la sorgente da
|
||||
cui WPT genera i propri test di parsing — e misura **93,88%** (6247 casi su 6654
|
||||
eseguibili, 166 saltati). Non è il WPT vero: i test di parsing del WPT sono pagine
|
||||
che girano in `testharness.js` e hanno bisogno di `DOMParser`,
|
||||
`createHTMLDocument` e di un event loop asincrono, che il motore non ha.
|
||||
Soglia in CI: 93%. Fuori ambito dichiarato: stati iniziali diversi da quello dei
|
||||
dati (RCDATA, CDATA, script, PLAINTEXT), `lastStartTag`, serializzazione.
|
||||
|
||||
- Motore JS integrato (decisione DA-1) con binding IDL generati.
|
||||
- Event loop, eventi, `fetch` sul processo di rete, stack HTTP/1.1 e HTTP/2, cache.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "117-sfondo-posizione-destra",
|
||||
"doc": "`background-position: right top` con tassello 20×20: il tassello sta a destra, a sinistra resta bianco.",
|
||||
"html": "<div style=\"width:100px;height:40px;background-image:url(quadrato-blu.png);background-size:20px 20px;background-repeat:no-repeat;background-position:right top\"></div>",
|
||||
"css": "",
|
||||
"viewport": [
|
||||
200,
|
||||
150
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"x": 90,
|
||||
"y": 10,
|
||||
"rgb": [
|
||||
0,
|
||||
0,
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 10,
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
]
|
||||
}
|
||||
],
|
||||
"boxes": []
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "118-sfondo-posizione-centro",
|
||||
"doc": "`background-position: center` centra il tassello 20×20 in un box 100×40: blu al centro, bianco ai lati.",
|
||||
"html": "<div style=\"width:100px;height:40px;background-image:url(quadrato-blu.png);background-size:20px 20px;background-repeat:no-repeat;background-position:center\"></div>",
|
||||
"css": "",
|
||||
"viewport": [
|
||||
200,
|
||||
150
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"x": 50,
|
||||
"y": 20,
|
||||
"rgb": [
|
||||
0,
|
||||
0,
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"x": 10,
|
||||
"y": 10,
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"x": 95,
|
||||
"y": 20,
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
]
|
||||
}
|
||||
],
|
||||
"boxes": []
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "119-sfondo-posizione-px",
|
||||
"doc": "`background-position: 10px 5px` dal box che parte a (8,8) come ogni body: il tassello 20×20 sta in 18..38 per 13..33.",
|
||||
"html": "<div style=\"width:100px;height:40px;background-image:url(quadrato-blu.png);background-size:20px 20px;background-repeat:no-repeat;background-position:10px 5px\"></div>",
|
||||
"css": "",
|
||||
"viewport": [
|
||||
200,
|
||||
150
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"x": 25,
|
||||
"y": 15,
|
||||
"rgb": [
|
||||
0,
|
||||
0,
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"x": 45,
|
||||
"y": 15,
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
]
|
||||
},
|
||||
{
|
||||
"x": 25,
|
||||
"y": 38,
|
||||
"rgb": [
|
||||
255,
|
||||
255,
|
||||
255
|
||||
]
|
||||
}
|
||||
],
|
||||
"boxes": []
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"PLAINTEXT content model flag",
|
||||
"initialStates":["PLAINTEXT state"],
|
||||
"lastStartTag":"plaintext",
|
||||
"input":"<head>&body;",
|
||||
"output":[["Character", "<head>&body;"]]},
|
||||
|
||||
{"description":"PLAINTEXT with seeming close tag",
|
||||
"initialStates":["PLAINTEXT state"],
|
||||
"lastStartTag":"plaintext",
|
||||
"input":"</plaintext>&body;",
|
||||
"output":[["Character", "</plaintext>&body;"]]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp>",
|
||||
"output":[["Character", "foo"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT (case-insensitivity)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xMp>",
|
||||
"output":[["Character", "foo"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT (ending with space)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp ",
|
||||
"output":[["Character", "foo"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT (ending with EOF)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp",
|
||||
"output":[["Character", "foo</xmp"]]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT (ending with slash)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp/",
|
||||
"output":[["Character", "foo"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"End tag not closing RCDATA or RAWTEXT (ending with left-angle-bracket)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp<",
|
||||
"output":[["Character", "foo</xmp<"]]},
|
||||
|
||||
{"description":"End tag with incorrect name in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</foo>bar</xmp>",
|
||||
"output":[["Character", "</foo>bar"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"Partial end tags leading straight into partial end tags",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</xmp</xmp</xmp>",
|
||||
"output":[["Character", "</xmp</xmp"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"End tag with incorrect name in RCDATA or RAWTEXT (starting like correct name)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</foo>bar</xmpaar>",
|
||||
"output":[["Character", "</foo>bar</xmpaar>"]]},
|
||||
|
||||
{"description":"End tag closing RCDATA or RAWTEXT, switching back to PCDATA",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo</xmp></baz>",
|
||||
"output":[["Character", "foo"], ["EndTag", "xmp"], ["EndTag", "baz"]]},
|
||||
|
||||
{"description":"RAWTEXT w/ something looking like an entity",
|
||||
"initialStates":["RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"&foo;",
|
||||
"output":[["Character", "&foo;"]]},
|
||||
|
||||
{"description":"RCDATA w/ an entity",
|
||||
"initialStates":["RCDATA state"],
|
||||
"lastStartTag":"textarea",
|
||||
"input":"<",
|
||||
"output":[["Character", "<"]]}
|
||||
|
||||
]}
|
||||
@@ -0,0 +1,311 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"description":"Raw NUL replacement",
|
||||
"doubleEscaped":true,
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "PLAINTEXT state", "Script data state"],
|
||||
"input":"\\u0000",
|
||||
"output":[["Character", "\\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 1 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"NUL in CDATA section",
|
||||
"doubleEscaped":true,
|
||||
"initialStates":["CDATA section state"],
|
||||
"input":"\\u0000]]>",
|
||||
"output":[["Character", "\\u0000"]]
|
||||
},
|
||||
{
|
||||
"description":"NUL in script HTML comment",
|
||||
"doubleEscaped":true,
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test\\u0000--><!--test-\\u0000--><!--test--\\u0000-->",
|
||||
"output":[["Character", "<!--test\\uFFFD--><!--test-\\uFFFD--><!--test--\\uFFFD-->"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 9 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 22 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 36 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"NUL in script HTML comment - double escaped",
|
||||
"doubleEscaped":true,
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>\\u0000--><!--<script>-\\u0000--><!--<script>--\\u0000-->",
|
||||
"output":[["Character", "<!--<script>\\uFFFD--><!--<script>-\\uFFFD--><!--<script>--\\uFFFD-->"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 13 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 30 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 48 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test",
|
||||
"output":[["Character", "<!--test"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 9 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment after dash",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test-",
|
||||
"output":[["Character", "<!--test-"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 10 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment after dash dash",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test--",
|
||||
"output":[["Character", "<!--test--"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 11 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment double escaped after dash",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>-",
|
||||
"output":[["Character", "<!--<script>-"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 14 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment double escaped after dash dash",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>--",
|
||||
"output":[["Character", "<!--<script>--"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 15 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"EOF in script HTML comment - double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>",
|
||||
"output":[["Character", "<!--<script>"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-script-html-comment-like-text", "line": 1, "col": 13 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"Dash in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- - -->",
|
||||
"output":[["Character", "<!-- - -->"]]
|
||||
},
|
||||
{
|
||||
"description":"Dash less-than in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- -< -->",
|
||||
"output":[["Character", "<!-- -< -->"]]
|
||||
},
|
||||
{
|
||||
"description":"Dash at end of script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test--->",
|
||||
"output":[["Character", "<!--test--->"]]
|
||||
},
|
||||
{
|
||||
"description":"</script> in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!-- </script> --></script>",
|
||||
"output":[["Character", "<!-- "], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
|
||||
},
|
||||
{
|
||||
"description":"</script> in script HTML comment - double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!-- <script></script> --></script>",
|
||||
"output":[["Character", "<!-- <script></script> -->"], ["EndTag", "script"]]
|
||||
},
|
||||
{
|
||||
"description":"</script> in script HTML comment - double escaped with nested <script>",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!-- <script><script></script></script> --></script>",
|
||||
"output":[["Character", "<!-- <script><script></script>"], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
|
||||
},
|
||||
{
|
||||
"description":"</script> in script HTML comment - double escaped with abrupt end",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!-- <script>--></script> --></script>",
|
||||
"output":[["Character", "<!-- <script>-->"], ["EndTag", "script"], ["Character", " -->"], ["EndTag", "script"]]
|
||||
},
|
||||
{
|
||||
"description":"Incomplete start tag in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!--<scrip></script>-->",
|
||||
"output":[["Character", "<!--<scrip>"], ["EndTag", "script"], ["Character", "-->"]]
|
||||
},
|
||||
{
|
||||
"description":"Unclosed start tag in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!--<script</script>-->",
|
||||
"output":[["Character", "<!--<script"], ["EndTag", "script"], ["Character", "-->"]]
|
||||
},
|
||||
{
|
||||
"description":"Incomplete end tag in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!--<script></scrip>-->",
|
||||
"output":[["Character", "<!--<script></scrip>-->"]]
|
||||
},
|
||||
{
|
||||
"description":"Unclosed end tag in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"lastStartTag":"script",
|
||||
"input":"<!--<script></script-->",
|
||||
"output":[["Character", "<!--<script></script-->"]]
|
||||
},
|
||||
{
|
||||
"description":"leading U+FEFF must pass through",
|
||||
"initialStates":["Data state", "RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"doubleEscaped":true,
|
||||
"input":"\\uFEFFfoo\\uFEFFbar",
|
||||
"output":[["Character", "\\uFEFFfoo\\uFEFFbar"]]
|
||||
},
|
||||
{
|
||||
"description":"Non BMP-charref in RCDATA",
|
||||
"initialStates":["RCDATA state"],
|
||||
"input":"≂̸",
|
||||
"output":[["Character", "\u2242\u0338"]]
|
||||
},
|
||||
{
|
||||
"description":"Bad charref in RCDATA",
|
||||
"initialStates":["RCDATA state"],
|
||||
"input":"&NotEqualTild;",
|
||||
"output":[["Character", "&NotEqualTild;"]],
|
||||
"errors":[
|
||||
{ "code": "unknown-named-character-reference", "line": 1, "col": 14 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"lowercase endtags",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</XMP>",
|
||||
"output":[["EndTag","xmp"]]
|
||||
},
|
||||
{
|
||||
"description":"bad endtag (space before name)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</ XMP>",
|
||||
"output":[["Character","</ XMP>"]]
|
||||
},
|
||||
{
|
||||
"description":"bad endtag (not matching last start tag)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</xm>",
|
||||
"output":[["Character","</xm>"]]
|
||||
},
|
||||
{
|
||||
"description":"bad endtag (without close bracket)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</xm ",
|
||||
"output":[["Character","</xm "]]
|
||||
},
|
||||
{
|
||||
"description":"bad endtag (trailing solidus)",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state", "Script data state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"</xm/",
|
||||
"output":[["Character","</xm/"]]
|
||||
},
|
||||
{
|
||||
"description":"Non BMP-charref in attribute",
|
||||
"input":"<p id=\"≂̸\">",
|
||||
"output":[["StartTag", "p", {"id":"\u2242\u0338"}]]
|
||||
},
|
||||
{
|
||||
"description":"--!NUL in comment ",
|
||||
"doubleEscaped":true,
|
||||
"input":"<!----!\\u0000-->",
|
||||
"output":[["Comment", "--!\\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 8 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"space EOF after doctype ",
|
||||
"input":"<!DOCTYPE html ",
|
||||
"output":[["DOCTYPE", "html", null, null , false]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-doctype", "line": 1, "col": 16 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"CDATA in HTML content",
|
||||
"input":"<![CDATA[foo]]>",
|
||||
"output":[["Comment", "[CDATA[foo]]"]],
|
||||
"errors":[
|
||||
{ "code": "cdata-in-html-content", "line": 1, "col": 9 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"CDATA content",
|
||||
"input":"foo ]]>",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo "]]
|
||||
},
|
||||
{
|
||||
"description":"CDATA followed by HTML content",
|
||||
"input":"foo ]]> ",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo  "]]
|
||||
},
|
||||
{
|
||||
"description":"CDATA with extra bracket",
|
||||
"input":"foo]]]>",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo]"]]
|
||||
},
|
||||
{
|
||||
"description":"CDATA without end marker",
|
||||
"input":"foo",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-cdata", "line": 1, "col": 4 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"CDATA with single bracket ending",
|
||||
"input":"foo]",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo]"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-cdata", "line": 1, "col": 5 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description":"CDATA with two brackets ending",
|
||||
"input":"foo]]",
|
||||
"initialStates":["CDATA section state"],
|
||||
"output":[["Character", "foo]]"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-cdata", "line": 1, "col": 6 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "HTML tag in script data",
|
||||
"input": "<b>hello world</b>",
|
||||
"initialStates": ["Script data state"],
|
||||
"output": [["Character", "<b>hello world</b>"]]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
{"tests": [
|
||||
|
||||
{"description": "Undefined named entity in a double-quoted attribute value ending in semicolon and whose name starts with a known entity name.",
|
||||
"input":"<h a=\"¬i;\">",
|
||||
"output": [["StartTag", "h", {"a": "¬i;"}]]},
|
||||
|
||||
{"description": "Entity name requiring semicolon instead followed by the equals sign in a double-quoted attribute value.",
|
||||
"input":"<h a=\"&lang=\">",
|
||||
"output": [["StartTag", "h", {"a": "&lang="}]]},
|
||||
|
||||
{"description": "Valid entity name followed by the equals sign in a double-quoted attribute value.",
|
||||
"input":"<h a=\"¬=\">",
|
||||
"output": [["StartTag", "h", {"a": "¬="}]]},
|
||||
|
||||
{"description": "Undefined named entity in a single-quoted attribute value ending in semicolon and whose name starts with a known entity name.",
|
||||
"input":"<h a='¬i;'>",
|
||||
"output": [["StartTag", "h", {"a": "¬i;"}]]},
|
||||
|
||||
{"description": "Entity name requiring semicolon instead followed by the equals sign in a single-quoted attribute value.",
|
||||
"input":"<h a='&lang='>",
|
||||
"output": [["StartTag", "h", {"a": "&lang="}]]},
|
||||
|
||||
{"description": "Valid entity name followed by the equals sign in a single-quoted attribute value.",
|
||||
"input":"<h a='¬='>",
|
||||
"output": [["StartTag", "h", {"a": "¬="}]]},
|
||||
|
||||
{"description": "Undefined named entity in an unquoted attribute value ending in semicolon and whose name starts with a known entity name.",
|
||||
"input":"<h a=¬i;>",
|
||||
"output": [["StartTag", "h", {"a": "¬i;"}]]},
|
||||
|
||||
{"description": "Entity name requiring semicolon instead followed by the equals sign in an unquoted attribute value.",
|
||||
"input":"<h a=&lang=>",
|
||||
"output": [["StartTag", "h", {"a": "&lang="}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description": "Valid entity name followed by the equals sign in an unquoted attribute value.",
|
||||
"input":"<h a=¬=>",
|
||||
"output": [["StartTag", "h", {"a": "¬="}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description": "Ambiguous ampersand.",
|
||||
"input":"&rrrraannddom;",
|
||||
"output": [["Character", "&rrrraannddom;"]],
|
||||
"errors":[
|
||||
{ "code": "unknown-named-character-reference", "line": 1, "col": 14 }
|
||||
]},
|
||||
|
||||
{"description": "Semicolonless named entity 'not' followed by 'i;' in body",
|
||||
"input":"¬i;",
|
||||
"output": [["Character", "\u00ACi;"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description": "Very long undefined named entity in body",
|
||||
"input":"&ammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmp;",
|
||||
"output": [["Character", "&ammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmp;"]],
|
||||
"errors":[
|
||||
{ "code": "unknown-named-character-reference", "line": 1, "col": 950 }
|
||||
]},
|
||||
|
||||
{"description": "CR as numeric entity",
|
||||
"input":"
",
|
||||
"output": [["Character", "\r"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description": "CR as hexadecimal numeric entity",
|
||||
"input":"
",
|
||||
"output": [["Character", "\r"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EURO SIGN numeric entity.",
|
||||
"input":"€",
|
||||
"output": [["Character", "\u20AC"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u0081"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE LOW-9 QUOTATION MARK numeric entity.",
|
||||
"input":"‚",
|
||||
"output": [["Character", "\u201A"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LETTER F WITH HOOK numeric entity.",
|
||||
"input":"ƒ",
|
||||
"output": [["Character", "\u0192"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DOUBLE LOW-9 QUOTATION MARK numeric entity.",
|
||||
"input":"„",
|
||||
"output": [["Character", "\u201E"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 HORIZONTAL ELLIPSIS numeric entity.",
|
||||
"input":"…",
|
||||
"output": [["Character", "\u2026"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DAGGER numeric entity.",
|
||||
"input":"†",
|
||||
"output": [["Character", "\u2020"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DOUBLE DAGGER numeric entity.",
|
||||
"input":"‡",
|
||||
"output": [["Character", "\u2021"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 MODIFIER LETTER CIRCUMFLEX ACCENT numeric entity.",
|
||||
"input":"ˆ",
|
||||
"output": [["Character", "\u02C6"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 PER MILLE SIGN numeric entity.",
|
||||
"input":"‰",
|
||||
"output": [["Character", "\u2030"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LETTER S WITH CARON numeric entity.",
|
||||
"input":"Š",
|
||||
"output": [["Character", "\u0160"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE LEFT-POINTING ANGLE QUOTATION MARK numeric entity.",
|
||||
"input":"‹",
|
||||
"output": [["Character", "\u2039"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LIGATURE OE numeric entity.",
|
||||
"input":"Œ",
|
||||
"output": [["Character", "\u0152"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u008D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LETTER Z WITH CARON numeric entity.",
|
||||
"input":"Ž",
|
||||
"output": [["Character", "\u017D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u008F"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u0090"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LEFT SINGLE QUOTATION MARK numeric entity.",
|
||||
"input":"‘",
|
||||
"output": [["Character", "\u2018"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 RIGHT SINGLE QUOTATION MARK numeric entity.",
|
||||
"input":"’",
|
||||
"output": [["Character", "\u2019"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LEFT DOUBLE QUOTATION MARK numeric entity.",
|
||||
"input":"“",
|
||||
"output": [["Character", "\u201C"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 RIGHT DOUBLE QUOTATION MARK numeric entity.",
|
||||
"input":"”",
|
||||
"output": [["Character", "\u201D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 BULLET numeric entity.",
|
||||
"input":"•",
|
||||
"output": [["Character", "\u2022"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EN DASH numeric entity.",
|
||||
"input":"–",
|
||||
"output": [["Character", "\u2013"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EM DASH numeric entity.",
|
||||
"input":"—",
|
||||
"output": [["Character", "\u2014"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SMALL TILDE numeric entity.",
|
||||
"input":"˜",
|
||||
"output": [["Character", "\u02DC"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 TRADE MARK SIGN numeric entity.",
|
||||
"input":"™",
|
||||
"output": [["Character", "\u2122"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LETTER S WITH CARON numeric entity.",
|
||||
"input":"š",
|
||||
"output": [["Character", "\u0161"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE RIGHT-POINTING ANGLE QUOTATION MARK numeric entity.",
|
||||
"input":"›",
|
||||
"output": [["Character", "\u203A"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LIGATURE OE numeric entity.",
|
||||
"input":"œ",
|
||||
"output": [["Character", "\u0153"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u009D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EURO SIGN hexadecimal numeric entity.",
|
||||
"input":"€",
|
||||
"output": [["Character", "\u20AC"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR hexadecimal numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u0081"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE LOW-9 QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"‚",
|
||||
"output": [["Character", "\u201A"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LETTER F WITH HOOK hexadecimal numeric entity.",
|
||||
"input":"ƒ",
|
||||
"output": [["Character", "\u0192"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DOUBLE LOW-9 QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"„",
|
||||
"output": [["Character", "\u201E"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 HORIZONTAL ELLIPSIS hexadecimal numeric entity.",
|
||||
"input":"…",
|
||||
"output": [["Character", "\u2026"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DAGGER hexadecimal numeric entity.",
|
||||
"input":"†",
|
||||
"output": [["Character", "\u2020"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 DOUBLE DAGGER hexadecimal numeric entity.",
|
||||
"input":"‡",
|
||||
"output": [["Character", "\u2021"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 MODIFIER LETTER CIRCUMFLEX ACCENT hexadecimal numeric entity.",
|
||||
"input":"ˆ",
|
||||
"output": [["Character", "\u02C6"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 PER MILLE SIGN hexadecimal numeric entity.",
|
||||
"input":"‰",
|
||||
"output": [["Character", "\u2030"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LETTER S WITH CARON hexadecimal numeric entity.",
|
||||
"input":"Š",
|
||||
"output": [["Character", "\u0160"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE LEFT-POINTING ANGLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"‹",
|
||||
"output": [["Character", "\u2039"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LIGATURE OE hexadecimal numeric entity.",
|
||||
"input":"Œ",
|
||||
"output": [["Character", "\u0152"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR hexadecimal numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u008D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LETTER Z WITH CARON hexadecimal numeric entity.",
|
||||
"input":"Ž",
|
||||
"output": [["Character", "\u017D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR hexadecimal numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u008F"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR hexadecimal numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u0090"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LEFT SINGLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"‘",
|
||||
"output": [["Character", "\u2018"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 RIGHT SINGLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"’",
|
||||
"output": [["Character", "\u2019"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LEFT DOUBLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"“",
|
||||
"output": [["Character", "\u201C"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 RIGHT DOUBLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"”",
|
||||
"output": [["Character", "\u201D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 BULLET hexadecimal numeric entity.",
|
||||
"input":"•",
|
||||
"output": [["Character", "\u2022"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EN DASH hexadecimal numeric entity.",
|
||||
"input":"–",
|
||||
"output": [["Character", "\u2013"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 EM DASH hexadecimal numeric entity.",
|
||||
"input":"—",
|
||||
"output": [["Character", "\u2014"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SMALL TILDE hexadecimal numeric entity.",
|
||||
"input":"˜",
|
||||
"output": [["Character", "\u02DC"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 TRADE MARK SIGN hexadecimal numeric entity.",
|
||||
"input":"™",
|
||||
"output": [["Character", "\u2122"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LETTER S WITH CARON hexadecimal numeric entity.",
|
||||
"input":"š",
|
||||
"output": [["Character", "\u0161"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 SINGLE RIGHT-POINTING ANGLE QUOTATION MARK hexadecimal numeric entity.",
|
||||
"input":"›",
|
||||
"output": [["Character", "\u203A"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LIGATURE OE hexadecimal numeric entity.",
|
||||
"input":"œ",
|
||||
"output": [["Character", "\u0153"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 REPLACEMENT CHAR hexadecimal numeric entity.",
|
||||
"input":"",
|
||||
"output": [["Character", "\u009D"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN SMALL LETTER Z WITH CARON hexadecimal numeric entity.",
|
||||
"input":"ž",
|
||||
"output": [["Character", "\u017E"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Windows-1252 LATIN CAPITAL LETTER Y WITH DIAERESIS hexadecimal numeric entity.",
|
||||
"input":"Ÿ",
|
||||
"output": [["Character", "\u0178"]],
|
||||
"errors":[
|
||||
{ "code": "control-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description": "Decimal numeric entity followed by hex character a.",
|
||||
"input":"aa",
|
||||
"output": [["Character", "aa"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description": "Decimal numeric entity followed by hex character A.",
|
||||
"input":"aA",
|
||||
"output": [["Character", "aA"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description": "Decimal numeric entity followed by hex character f.",
|
||||
"input":"af",
|
||||
"output": [["Character", "af"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description": "Decimal numeric entity followed by hex character A.",
|
||||
"input":"aF",
|
||||
"output": [["Character", "aF"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 }
|
||||
]}
|
||||
|
||||
]}
|
||||
@@ -0,0 +1,36 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"Commented close tag in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!--</xmp>--></xmp>",
|
||||
"output":[["Character", "foo<!--"], ["EndTag", "xmp"], ["Character", "-->"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"Bogus comment in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!-->baz</xmp>",
|
||||
"output":[["Character", "foo<!-->baz"], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"End tag surrounded by bogus comment in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!--></xmp><!-->baz</xmp>",
|
||||
"output":[["Character", "foo<!-->"], ["EndTag", "xmp"], ["Comment", ""], ["Character", "baz"], ["EndTag", "xmp"]],
|
||||
"errors":[
|
||||
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 19 }
|
||||
]},
|
||||
|
||||
{"description":"Commented entities in RCDATA",
|
||||
"initialStates":["RCDATA state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":" & <!-- & --> & </xmp>",
|
||||
"output":[["Character", " & <!-- & --> & "], ["EndTag", "xmp"]]},
|
||||
|
||||
{"description":"Incorrect comment ending sequences in RCDATA or RAWTEXT",
|
||||
"initialStates":["RCDATA state", "RAWTEXT state"],
|
||||
"lastStartTag":"xmp",
|
||||
"input":"foo<!-- x --x>x-- >x--!>x--<></xmp>",
|
||||
"output":[["Character", "foo<!-- x --x>x-- >x--!>x--<>"], ["EndTag", "xmp"]]}
|
||||
|
||||
]}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"<!---- >",
|
||||
"input":"<!---- >",
|
||||
"output":[["Comment","-- >"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-comment", "line": 1, "col": 9 }
|
||||
]}
|
||||
]}
|
||||
@@ -0,0 +1,353 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"Correct Doctype lowercase",
|
||||
"input":"<!DOCTYPE html>",
|
||||
"output":[["DOCTYPE", "html", null, null, true]]},
|
||||
|
||||
|
||||
{"description":"Correct Doctype uppercase",
|
||||
"input":"<!DOCTYPE HTML>",
|
||||
"output":[["DOCTYPE", "html", null, null, true]]},
|
||||
|
||||
{"description":"Correct Doctype mixed case",
|
||||
"input":"<!DOCTYPE HtMl>",
|
||||
"output":[["DOCTYPE", "html", null, null, true]]},
|
||||
|
||||
{"description":"Correct Doctype case with EOF",
|
||||
"input":"<!DOCTYPE HtMl",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-doctype", "line": 1, "col": 15 }
|
||||
]},
|
||||
|
||||
{"description":"Truncated doctype start",
|
||||
"input":"<!DOC>",
|
||||
"output":[["Comment", "DOC"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype in error",
|
||||
"input":"<!DOCTYPE foo>",
|
||||
"output":[["DOCTYPE", "foo", null, null, true]]},
|
||||
|
||||
{"description":"Single Start Tag",
|
||||
"input":"<h>",
|
||||
"output":[["StartTag", "h", {}]]},
|
||||
|
||||
{"description":"Empty end tag",
|
||||
"input":"</>",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "missing-end-tag-name", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Empty start tag",
|
||||
"input":"<>",
|
||||
"output":[["Character", "<>"]],
|
||||
"errors":[
|
||||
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 2 }
|
||||
]},
|
||||
|
||||
{"description":"Start Tag w/attribute",
|
||||
"input":"<h a='b'>",
|
||||
"output":[["StartTag", "h", {"a":"b"}]]},
|
||||
|
||||
{"description":"Start Tag w/attribute no quotes",
|
||||
"input":"<h a=b>",
|
||||
"output":[["StartTag", "h", {"a":"b"}]]},
|
||||
|
||||
{"description":"Start/End Tag",
|
||||
"input":"<h></h>",
|
||||
"output":[["StartTag", "h", {}], ["EndTag", "h"]]},
|
||||
|
||||
{"description":"Two unclosed start tags",
|
||||
"input":"<p>One<p>Two",
|
||||
"output":[["StartTag", "p", {}], ["Character", "One"], ["StartTag", "p", {}], ["Character", "Two"]]},
|
||||
|
||||
{"description":"End Tag w/attribute",
|
||||
"input":"<h></h a='b'>",
|
||||
"output":[["StartTag", "h", {}], ["EndTag", "h"]],
|
||||
"errors":[
|
||||
{ "code": "end-tag-with-attributes", "line": 1, "col": 13 }
|
||||
]},
|
||||
|
||||
{"description":"Multiple atts",
|
||||
"input":"<h a='b' c='d'>",
|
||||
"output":[["StartTag", "h", {"a":"b", "c":"d"}]]},
|
||||
|
||||
{"description":"Multiple atts no space",
|
||||
"input":"<h a='b'c='d'>",
|
||||
"output":[["StartTag", "h", {"a":"b", "c":"d"}]],
|
||||
"errors":[
|
||||
{ "code": "missing-whitespace-between-attributes", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"Repeated attr",
|
||||
"input":"<h a='b' a='d'>",
|
||||
"output":[["StartTag", "h", {"a":"b"}]],
|
||||
"errors":[
|
||||
{ "code": "duplicate-attribute", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"Simple comment",
|
||||
"input":"<!--comment-->",
|
||||
"output":[["Comment", "comment"]]},
|
||||
|
||||
{"description":"Comment, Central dash no space",
|
||||
"input":"<!----->",
|
||||
"output":[["Comment", "-"]]},
|
||||
|
||||
{"description":"Comment, two central dashes",
|
||||
"input":"<!-- --comment -->",
|
||||
"output":[["Comment", " --comment "]]},
|
||||
|
||||
{"description":"Comment, central less-than bang",
|
||||
"input":"<!--<!-->",
|
||||
"output":[["Comment", "<!"]]},
|
||||
|
||||
{"description":"Unfinished comment",
|
||||
"input":"<!--comment",
|
||||
"output":[["Comment", "comment"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-comment", "line": 1, "col": 12 }
|
||||
]},
|
||||
|
||||
{"description":"Unfinished comment after start of nested comment",
|
||||
"input":"<!-- <!--",
|
||||
"output":[["Comment", " <!"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-comment", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"Start of a comment",
|
||||
"input":"<!-",
|
||||
"output":[["Comment", "-"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Short comment",
|
||||
"input":"<!-->",
|
||||
"output":[["Comment", ""]],
|
||||
"errors":[
|
||||
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description":"Short comment two",
|
||||
"input":"<!--->",
|
||||
"output":[["Comment", ""]],
|
||||
"errors":[
|
||||
{ "code": "abrupt-closing-of-empty-comment", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Short comment three",
|
||||
"input":"<!---->",
|
||||
"output":[["Comment", ""]]},
|
||||
|
||||
{"description":"< in comment",
|
||||
"input":"<!-- <test-->",
|
||||
"output":[["Comment", " <test"]]},
|
||||
|
||||
{"description":"<< in comment",
|
||||
"input":"<!--<<-->",
|
||||
"output":[["Comment", "<<"]]},
|
||||
|
||||
{"description":"<! in comment",
|
||||
"input":"<!-- <!test-->",
|
||||
"output":[["Comment", " <!test"]]},
|
||||
|
||||
{"description":"<!- in comment",
|
||||
"input":"<!-- <!-test-->",
|
||||
"output":[["Comment", " <!-test"]]},
|
||||
|
||||
{"description":"Nested comment",
|
||||
"input":"<!-- <!--test-->",
|
||||
"output":[["Comment", " <!--test"]],
|
||||
"errors":[
|
||||
{ "code": "nested-comment", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"Nested comment with extra <",
|
||||
"input":"<!-- <<!--test-->",
|
||||
"output":[["Comment", " <<!--test"]],
|
||||
"errors":[
|
||||
{ "code": "nested-comment", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"< in script data",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<test-->",
|
||||
"output":[["Character", "<test-->"]]},
|
||||
|
||||
{"description":"<! in script data",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!test-->",
|
||||
"output":[["Character", "<!test-->"]]},
|
||||
|
||||
{"description":"<!- in script data",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-test-->",
|
||||
"output":[["Character", "<!-test-->"]]},
|
||||
|
||||
{"description":"Escaped script data",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--test-->",
|
||||
"output":[["Character", "<!--test-->"]]},
|
||||
|
||||
{"description":"< in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- < test -->",
|
||||
"output":[["Character", "<!-- < test -->"]]},
|
||||
|
||||
{"description":"</ in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- </ test -->",
|
||||
"output":[["Character", "<!-- </ test -->"]]},
|
||||
|
||||
{"description":"Start tag in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- <test> -->",
|
||||
"output":[["Character", "<!-- <test> -->"]]},
|
||||
|
||||
{"description":"End tag in script HTML comment",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!-- </test> -->",
|
||||
"output":[["Character", "<!-- </test> -->"]]},
|
||||
|
||||
{"description":"- in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>-</script>-->",
|
||||
"output":[["Character", "<!--<script>-</script>-->"]]},
|
||||
|
||||
{"description":"-- in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>--</script>-->",
|
||||
"output":[["Character", "<!--<script>--</script>-->"]]},
|
||||
|
||||
{"description":"--- in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script>---</script>-->",
|
||||
"output":[["Character", "<!--<script>---</script>-->"]]},
|
||||
|
||||
{"description":"- spaced in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script> - </script>-->",
|
||||
"output":[["Character", "<!--<script> - </script>-->"]]},
|
||||
|
||||
{"description":"-- spaced in script HTML comment double escaped",
|
||||
"initialStates":["Script data state"],
|
||||
"input":"<!--<script> -- </script>-->",
|
||||
"output":[["Character", "<!--<script> -- </script>-->"]]},
|
||||
|
||||
{"description":"Ampersand EOF",
|
||||
"input":"&",
|
||||
"output":[["Character", "&"]]},
|
||||
|
||||
{"description":"Ampersand ampersand EOF",
|
||||
"input":"&&",
|
||||
"output":[["Character", "&&"]]},
|
||||
|
||||
{"description":"Ampersand space EOF",
|
||||
"input":"& ",
|
||||
"output":[["Character", "& "]]},
|
||||
|
||||
{"description":"Unfinished entity",
|
||||
"input":"&f",
|
||||
"output":[["Character", "&f"]]},
|
||||
|
||||
{"description":"Ampersand, number sign",
|
||||
"input":"&#",
|
||||
"output":[["Character", "&#"]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Unfinished numeric entity",
|
||||
"input":"&#x",
|
||||
"output":[["Character", "&#x"]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Entity with trailing semicolon (1)",
|
||||
"input":"I'm ¬it",
|
||||
"output":[["Character","I'm \u00ACit"]]},
|
||||
|
||||
{"description":"Entity with trailing semicolon (2)",
|
||||
"input":"I'm ∉",
|
||||
"output":[["Character","I'm \u2209"]]},
|
||||
|
||||
{"description":"Entity without trailing semicolon (1)",
|
||||
"input":"I'm ¬it",
|
||||
"output":[["Character","I'm \u00ACit"]],
|
||||
"errors": [
|
||||
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"Entity without trailing semicolon (2)",
|
||||
"input":"I'm ¬in",
|
||||
"output":[["Character","I'm \u00ACin"]],
|
||||
"errors": [
|
||||
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"Partial entity match at end of file",
|
||||
"input":"I'm &no",
|
||||
"output":[["Character","I'm &no"]]},
|
||||
|
||||
{"description":"Non-ASCII character reference name",
|
||||
"input":"&\u00AC;",
|
||||
"output":[["Character", "&\u00AC;"]]},
|
||||
|
||||
{"description":"ASCII decimal entity",
|
||||
"input":"$",
|
||||
"output":[["Character","$"]]},
|
||||
|
||||
{"description":"ASCII hexadecimal entity",
|
||||
"input":"?",
|
||||
"output":[["Character","?"]]},
|
||||
|
||||
{"description":"Hexadecimal entity in attribute",
|
||||
"input":"<h a='?'></h>",
|
||||
"output":[["StartTag", "h", {"a":"?"}], ["EndTag", "h"]]},
|
||||
|
||||
{"description":"Entity in attribute without semicolon ending in x",
|
||||
"input":"<h a='¬x'>",
|
||||
"output":[["StartTag", "h", {"a":"¬x"}]]},
|
||||
|
||||
{"description":"Entity in attribute without semicolon ending in 1",
|
||||
"input":"<h a='¬1'>",
|
||||
"output":[["StartTag", "h", {"a":"¬1"}]]},
|
||||
|
||||
{"description":"Entity in attribute without semicolon ending in i",
|
||||
"input":"<h a='¬i'>",
|
||||
"output":[["StartTag", "h", {"a":"¬i"}]]},
|
||||
|
||||
{"description":"Entity in attribute without semicolon",
|
||||
"input":"<h a='©'>",
|
||||
"output":[["StartTag", "h", {"a":"\u00A9"}]],
|
||||
"errors": [
|
||||
{"code" : "missing-semicolon-after-character-reference", "line": 1, "col": 12 }
|
||||
]},
|
||||
|
||||
{"description":"Unquoted attribute ending in ampersand",
|
||||
"input":"<s o=& t>",
|
||||
"output":[["StartTag","s",{"o":"&","t":""}]]},
|
||||
|
||||
{"description":"Unquoted attribute at end of tag with final character of &, with tag followed by characters",
|
||||
"input":"<a a=a&>foo",
|
||||
"output":[["StartTag", "a", {"a":"a&"}], ["Character", "foo"]]},
|
||||
|
||||
{"description":"plaintext element",
|
||||
"input":"<plaintext>foobar",
|
||||
"output":[["StartTag","plaintext",{}], ["Character","foobar"]]},
|
||||
|
||||
{"description":"Open angled bracket in unquoted attribute value state",
|
||||
"input":"<a a=f<>",
|
||||
"output":[["StartTag", "a", {"a":"f<"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 7 }
|
||||
]}
|
||||
|
||||
]}
|
||||
@@ -0,0 +1,273 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"DOCTYPE without name",
|
||||
"input":"<!DOCTYPE>",
|
||||
"output":[["DOCTYPE", null, null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "missing-doctype-name", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE without space before name",
|
||||
"input":"<!DOCTYPEhtml>",
|
||||
"output":[["DOCTYPE", "html", null, null, true]],
|
||||
"errors":[
|
||||
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"Incorrect DOCTYPE without a space before name",
|
||||
"input":"<!DOCTYPEfoo>",
|
||||
"output":[["DOCTYPE", "foo", null, null, true]],
|
||||
"errors":[
|
||||
{ "code": "missing-whitespace-before-doctype-name", "line": 1, "col": 10 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with publicId",
|
||||
"input":"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
||||
"output":[["DOCTYPE", "html", "-//W3C//DTD HTML Transitional 4.01//EN", null, true]]},
|
||||
|
||||
{"description":"DOCTYPE with EOF after PUBLIC",
|
||||
"input":"<!DOCTYPE html PUBLIC",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors": [
|
||||
{ "code": "eof-in-doctype", "col": 22, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with EOF after PUBLIC '",
|
||||
"input":"<!DOCTYPE html PUBLIC '",
|
||||
"output":[["DOCTYPE", "html", "", null, false]],
|
||||
"errors": [
|
||||
{ "code": "eof-in-doctype", "col": 24, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with EOF after PUBLIC 'x",
|
||||
"input":"<!DOCTYPE html PUBLIC 'x",
|
||||
"output":[["DOCTYPE", "html", "x", null, false]],
|
||||
"errors": [
|
||||
{ "code": "eof-in-doctype", "col": 25, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with systemId",
|
||||
"input":"<!DOCTYPE html SYSTEM \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
||||
"output":[["DOCTYPE", "html", null, "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
||||
|
||||
{"description":"DOCTYPE with single-quoted systemId",
|
||||
"input":"<!DOCTYPE html SYSTEM '-//W3C//DTD HTML Transitional 4.01//EN'>",
|
||||
"output":[["DOCTYPE", "html", null, "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
||||
|
||||
{"description":"DOCTYPE with publicId and systemId",
|
||||
"input":"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML Transitional 4.01//EN\" \"-//W3C//DTD HTML Transitional 4.01//EN\">",
|
||||
"output":[["DOCTYPE", "html", "-//W3C//DTD HTML Transitional 4.01//EN", "-//W3C//DTD HTML Transitional 4.01//EN", true]]},
|
||||
|
||||
{"description":"DOCTYPE with > in double-quoted publicId",
|
||||
"input":"<!DOCTYPE html PUBLIC \">x",
|
||||
"output":[["DOCTYPE", "html", "", null, false], ["Character", "x"]],
|
||||
"errors": [
|
||||
{ "code": "abrupt-doctype-public-identifier", "col": 24, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with > in single-quoted publicId",
|
||||
"input":"<!DOCTYPE html PUBLIC '>x",
|
||||
"output":[["DOCTYPE", "html", "", null, false], ["Character", "x"]],
|
||||
"errors": [
|
||||
{ "code": "abrupt-doctype-public-identifier", "col": 24, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with > in double-quoted systemId",
|
||||
"input":"<!DOCTYPE html PUBLIC \"foo\" \">x",
|
||||
"output":[["DOCTYPE", "html", "foo", "", false], ["Character", "x"]],
|
||||
"errors": [
|
||||
{ "code": "abrupt-doctype-system-identifier", "col": 30, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"DOCTYPE with > in single-quoted systemId",
|
||||
"input":"<!DOCTYPE html PUBLIC 'foo' '>x",
|
||||
"output":[["DOCTYPE", "html", "foo", "", false], ["Character", "x"]],
|
||||
"errors": [
|
||||
{ "code": "abrupt-doctype-system-identifier", "col": 30, "line": 1 }
|
||||
]},
|
||||
|
||||
{"description":"Incomplete doctype",
|
||||
"input":"<!DOCTYPE html ",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-doctype", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Numeric entity representing the NUL character",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "null-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description":"Hexadecimal entity representing the NUL character",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "null-character-reference", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"Numeric entity representing a codepoint after 1114111 (U+10FFFF)",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"Hexadecimal entity representing a codepoint after 1114111 (U+10FFFF)",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 13 }
|
||||
]},
|
||||
|
||||
{"description":"Hexadecimal entity pair representing a surrogate pair",
|
||||
"input":"��",
|
||||
"output":[["Character", "\uFFFD\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 9 },
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 17 }
|
||||
]},
|
||||
|
||||
{"description":"Hexadecimal entity with mixed uppercase and lowercase",
|
||||
"input":"ꯍ",
|
||||
"output":[["Character", "\uABCD"]]},
|
||||
|
||||
{"description":"Entity without a name",
|
||||
"input":"&;",
|
||||
"output":[["Character", "&;"]]},
|
||||
|
||||
{"description":"Unescaped ampersand in attribute value",
|
||||
"input":"<h a='&'>",
|
||||
"output":[["StartTag", "h", { "a":"&" }]]},
|
||||
|
||||
|
||||
{"description":"StartTag containing <",
|
||||
"input":"<a<b>",
|
||||
"output":[["StartTag", "a<b", { }]]},
|
||||
|
||||
{"description":"Non-void element containing trailing /",
|
||||
"input":"<h/>",
|
||||
"output":[["StartTag","h",{},true]]},
|
||||
|
||||
{"description":"Void element with permitted slash",
|
||||
"input":"<br/>",
|
||||
"output":[["StartTag","br",{},true]]},
|
||||
|
||||
{"description":"Void element with permitted slash (with attribute)",
|
||||
"input":"<br foo='bar'/>",
|
||||
"output":[["StartTag","br",{"foo":"bar"},true]]},
|
||||
|
||||
{"description":"StartTag containing /",
|
||||
"input":"<h/a='b'>",
|
||||
"output":[["StartTag", "h", { "a":"b" }]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-solidus-in-tag", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Double-quoted attribute value",
|
||||
"input":"<h a=\"b\">",
|
||||
"output":[["StartTag", "h", { "a":"b" }]]},
|
||||
|
||||
{"description":"Unescaped </",
|
||||
"input":"</",
|
||||
"output":[["Character", "</"]],
|
||||
"errors":[
|
||||
{ "code": "eof-before-tag-name", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Illegal end tag name",
|
||||
"input":"</1>",
|
||||
"output":[["Comment", "1"]],
|
||||
"errors":[
|
||||
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Processing instruction",
|
||||
"input":"<?namespace>",
|
||||
"output":[["ProcessingInstruction", "namespace", ""]]},
|
||||
|
||||
{"description":"A processing instruction delimited by ?> doesn't contain the delimiting ?",
|
||||
"input":"<?foo bar?>",
|
||||
"output":[["ProcessingInstruction", "foo", "bar"]]},
|
||||
|
||||
{"description":"A processing instruction's data delimited by ?> contains the correct amount of ?",
|
||||
"input":"<?foo bar??>",
|
||||
"output":[["ProcessingInstruction", "foo", "bar?"]]},
|
||||
|
||||
{"description":"Unescaped <",
|
||||
"input":"foo < bar",
|
||||
"output":[["Character", "foo < bar"]],
|
||||
"errors":[
|
||||
{ "code": "invalid-first-character-of-tag-name", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Null Byte Replacement",
|
||||
"input":"\u0000",
|
||||
"output":[["Character", "\u0000"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description":"Comment with dash",
|
||||
"input":"<!---x",
|
||||
"output":[["Comment", "-x"]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-comment", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"Entity + newline",
|
||||
"input":"\nx\n>\n",
|
||||
"output":[["Character","\nx\n>\n"]]},
|
||||
|
||||
{"description":"Start tag with no attributes but space before the greater-than sign",
|
||||
"input":"<h >",
|
||||
"output":[["StartTag", "h", {}]]},
|
||||
|
||||
{"description":"Empty attribute followed by uppercase attribute",
|
||||
"input":"<h a B=''>",
|
||||
"output":[["StartTag", "h", {"a":"", "b":""}]]},
|
||||
|
||||
{"description":"Double-quote after attribute name",
|
||||
"input":"<h a \">",
|
||||
"output":[["StartTag", "h", {"a":"", "\"":""}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Single-quote after attribute name",
|
||||
"input":"<h a '>",
|
||||
"output":[["StartTag", "h", {"a":"", "'":""}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Empty end tag with following characters",
|
||||
"input":"a</>bc",
|
||||
"output":[["Character", "abc"]],
|
||||
"errors":[
|
||||
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Empty end tag with following tag",
|
||||
"input":"a</><b>c",
|
||||
"output":[["Character", "a"], ["StartTag", "b", {}], ["Character", "c"]],
|
||||
"errors":[
|
||||
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Empty end tag with following comment",
|
||||
"input":"a</><!--b-->c",
|
||||
"output":[["Character", "a"], ["Comment", "b"], ["Character", "c"]],
|
||||
"errors":[
|
||||
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Empty end tag with following end tag",
|
||||
"input":"a</></b>c",
|
||||
"output":[["Character", "a"], ["EndTag", "b"], ["Character", "c"]],
|
||||
"errors":[
|
||||
{ "code": "missing-end-tag-name", "line": 1, "col": 4 }
|
||||
]}
|
||||
|
||||
]}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,532 @@
|
||||
{"tests": [
|
||||
|
||||
{"description":"< in attribute name",
|
||||
"input":"<z/0 <>",
|
||||
"output":[["StartTag", "z", {"0": "", "<": ""}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-solidus-in-tag", "line": 1, "col": 4 },
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"< in unquoted attribute value",
|
||||
"input":"<z x=<>",
|
||||
"output":[["StartTag", "z", {"x": "<"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"= in unquoted attribute value",
|
||||
"input":"<z z=z=z>",
|
||||
"output":[["StartTag", "z", {"z": "z=z"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"= attribute",
|
||||
"input":"<z =>",
|
||||
"output":[["StartTag", "z", {"=": ""}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-equals-sign-before-attribute-name", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"== attribute",
|
||||
"input":"<z ==>",
|
||||
"output":[["StartTag", "z", {"=": ""}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-equals-sign-before-attribute-name", "line": 1, "col": 4 },
|
||||
{ "code": "missing-attribute-value", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"=== attribute",
|
||||
"input":"<z ===>",
|
||||
"output":[["StartTag", "z", {"=": "="}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-equals-sign-before-attribute-name", "line": 1, "col": 4 },
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"==== attribute",
|
||||
"input":"<z ====>",
|
||||
"output":[["StartTag", "z", {"=": "=="}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-equals-sign-before-attribute-name", "line": 1, "col": 4 },
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 6 },
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"\" after ampersand in double-quoted attribute value",
|
||||
"input":"<z z=\"&\">",
|
||||
"output":[["StartTag", "z", {"z": "&"}]]},
|
||||
|
||||
{"description":"' after ampersand in double-quoted attribute value",
|
||||
"input":"<z z=\"&'\">",
|
||||
"output":[["StartTag", "z", {"z": "&'"}]]},
|
||||
|
||||
{"description":"' after ampersand in single-quoted attribute value",
|
||||
"input":"<z z='&'>",
|
||||
"output":[["StartTag", "z", {"z": "&"}]]},
|
||||
|
||||
{"description":"\" after ampersand in single-quoted attribute value",
|
||||
"input":"<z z='&\"'>",
|
||||
"output":[["StartTag", "z", {"z": "&\""}]]},
|
||||
|
||||
{"description":"Text after bogus character reference",
|
||||
"input":"<z z='&xlink_xmlns;'>bar<z>",
|
||||
"output":[["StartTag","z",{"z":"&xlink_xmlns;"}],["Character","bar"],["StartTag","z",{}]]},
|
||||
|
||||
{"description":"Text after hex character reference",
|
||||
"input":"<z z='  foo'>bar<z>",
|
||||
"output":[["StartTag","z",{"z":" foo"}],["Character","bar"],["StartTag","z",{}]]},
|
||||
|
||||
{"description":"Attribute name starting with \"",
|
||||
"input":"<foo \"='bar'>",
|
||||
"output":[["StartTag", "foo", {"\"": "bar"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Attribute name starting with '",
|
||||
"input":"<foo '='bar'>",
|
||||
"output":[["StartTag", "foo", {"'": "bar"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Attribute name containing \"",
|
||||
"input":"<foo a\"b='bar'>",
|
||||
"output":[["StartTag", "foo", {"a\"b": "bar"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"Attribute name containing '",
|
||||
"input":"<foo a'b='bar'>",
|
||||
"output":[["StartTag", "foo", {"a'b": "bar"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-attribute-name", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"Unquoted attribute value containing '",
|
||||
"input":"<foo a=b'c>",
|
||||
"output":[["StartTag", "foo", {"a": "b'c"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
|
||||
{"description":"Unquoted attribute value containing \"",
|
||||
"input":"<foo a=b\"c>",
|
||||
"output":[["StartTag", "foo", {"a": "b\"c"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"Double-quoted attribute value not followed by whitespace",
|
||||
"input":"<foo a=\"b\"c>",
|
||||
"output":[["StartTag", "foo", {"a": "b", "c": ""}]],
|
||||
"errors":[
|
||||
{ "code": "missing-whitespace-between-attributes", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"Single-quoted attribute value not followed by whitespace",
|
||||
"input":"<foo a='b'c>",
|
||||
"output":[["StartTag", "foo", {"a": "b", "c": ""}]],
|
||||
"errors":[
|
||||
{ "code": "missing-whitespace-between-attributes", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"Quoted attribute followed by permitted /",
|
||||
"input":"<br a='b'/>",
|
||||
"output":[["StartTag","br",{"a":"b"},true]]},
|
||||
|
||||
{"description":"Quoted attribute followed by non-permitted /",
|
||||
"input":"<bar a='b'/>",
|
||||
"output":[["StartTag","bar",{"a":"b"},true]]},
|
||||
|
||||
{"description":"CR EOF after doctype name",
|
||||
"input":"<!doctype html \r",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "eof-in-doctype", "line": 2, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description":"CR EOF in tag name",
|
||||
"input":"<z\r",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 2, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description":"Slash EOF in tag name",
|
||||
"input":"<z/",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Zero hex numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 5 },
|
||||
{ "code": "null-character-reference", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description":"Zero decimal numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "missing-semicolon-after-character-reference", "line": 1, "col": 4 },
|
||||
{ "code": "null-character-reference", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Zero-prefixed hex numeric entity",
|
||||
"input":"A",
|
||||
"output":[["Character", "A"]]},
|
||||
|
||||
{"description":"Zero-prefixed decimal numeric entity",
|
||||
"input":"A",
|
||||
"output":[["Character", "A"]]},
|
||||
|
||||
{"description":"Empty hex numeric entities",
|
||||
"input":"&#x &#X ",
|
||||
"output":[["Character", "&#x &#X "]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 4 },
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description":"Invalid digit in hex numeric entity",
|
||||
"input":"&#xZ",
|
||||
"output":[["Character", "&#xZ"]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"Empty decimal numeric entities",
|
||||
"input":"&# &#; ",
|
||||
"output":[["Character", "&# &#; "]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 3 },
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Invalid digit in decimal numeric entity",
|
||||
"input":"&#A",
|
||||
"output":[["Character", "&#A"]],
|
||||
"errors":[
|
||||
{ "code": "absence-of-digits-in-numeric-character-reference", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"Non-BMP numeric entity",
|
||||
"input":"𐀀",
|
||||
"output":[["Character", "\uD800\uDC00"]]},
|
||||
|
||||
{"description":"Maximum non-BMP numeric entity",
|
||||
"input":"",
|
||||
"output":[["Character", "\uDBFF\uDFFF"]],
|
||||
"errors":[
|
||||
{ "code": "noncharacter-character-reference", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
|
||||
{"description":"Above maximum numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 11 }
|
||||
]},
|
||||
|
||||
{"description":"32-bit hex numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 13 }
|
||||
]},
|
||||
|
||||
{"description":"33-bit hex numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 14 }
|
||||
]},
|
||||
|
||||
{"description":"33-bit decimal numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 14 }
|
||||
]},
|
||||
|
||||
{"description":"65-bit hex numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 22 }
|
||||
]},
|
||||
|
||||
{"description":"65-bit decimal numeric entity",
|
||||
"input":"�",
|
||||
"output":[["Character", "\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "character-reference-outside-unicode-range", "line": 1, "col": 24 }
|
||||
]},
|
||||
|
||||
{"description":"Surrogate code point edge cases",
|
||||
"input":"퟿����",
|
||||
"output":[["Character", "\uD7FF\uFFFD\uFFFD\uFFFD\uFFFD\uE000"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 17 },
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 25 },
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 33 },
|
||||
{ "code": "surrogate-character-reference", "line": 1, "col": 41 }
|
||||
]},
|
||||
|
||||
{"description":"Uppercase start tag name",
|
||||
"input":"<X>",
|
||||
"output":[["StartTag", "x", {}]]},
|
||||
|
||||
{"description":"Uppercase end tag name",
|
||||
"input":"</X>",
|
||||
"output":[["EndTag", "x"]]},
|
||||
|
||||
{"description":"Uppercase attribute name",
|
||||
"input":"<x X>",
|
||||
"output":[["StartTag", "x", { "x":"" }]]},
|
||||
|
||||
{"description":"Tag/attribute name case edge values",
|
||||
"input":"<x@AZ[`az{ @AZ[`az{>",
|
||||
"output":[["StartTag", "x@az[`az{", { "@az[`az{":"" }]]},
|
||||
|
||||
{"description":"Duplicate different-case attributes",
|
||||
"input":"<x x=1 x=2 X=3>",
|
||||
"output":[["StartTag", "x", { "x":"1" }]],
|
||||
"errors":[
|
||||
{ "code": "duplicate-attribute", "line": 1, "col": 9 },
|
||||
{ "code": "duplicate-attribute", "line": 1, "col": 13 }
|
||||
]},
|
||||
|
||||
{"description":"Uppercase close tag attributes",
|
||||
"input":"</x X>",
|
||||
"output":[["EndTag", "x"]],
|
||||
"errors":[
|
||||
{ "code": "end-tag-with-attributes", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Duplicate close tag attributes",
|
||||
"input":"</x x x>",
|
||||
"output":[["EndTag", "x"]],
|
||||
"errors":[
|
||||
{ "code": "duplicate-attribute", "line": 1, "col": 8 },
|
||||
{ "code": "end-tag-with-attributes", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description":"Permitted slash",
|
||||
"input":"<br/>",
|
||||
"output":[["StartTag","br",{},true]]},
|
||||
|
||||
{"description":"Non-permitted slash",
|
||||
"input":"<xr/>",
|
||||
"output":[["StartTag","xr",{},true]]},
|
||||
|
||||
{"description":"Permitted slash but in close tag",
|
||||
"input":"</br/>",
|
||||
"output":[["EndTag", "br"]],
|
||||
"errors":[
|
||||
{ "code": "end-tag-with-trailing-solidus", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype public case-sensitivity (1)",
|
||||
"input":"<!DoCtYpE HtMl PuBlIc \"AbC\" \"XyZ\">",
|
||||
"output":[["DOCTYPE", "html", "AbC", "XyZ", true]]},
|
||||
|
||||
{"description":"Doctype public case-sensitivity (2)",
|
||||
"input":"<!dOcTyPe hTmL pUbLiC \"aBc\" \"xYz\">",
|
||||
"output":[["DOCTYPE", "html", "aBc", "xYz", true]]},
|
||||
|
||||
{"description":"Doctype system case-sensitivity (1)",
|
||||
"input":"<!DoCtYpE HtMl SyStEm \"XyZ\">",
|
||||
"output":[["DOCTYPE", "html", null, "XyZ", true]]},
|
||||
|
||||
{"description":"Doctype system case-sensitivity (2)",
|
||||
"input":"<!dOcTyPe hTmL sYsTeM \"xYz\">",
|
||||
"output":[["DOCTYPE", "html", null, "xYz", true]]},
|
||||
|
||||
{"description":"U+0000 in lookahead region after non-matching character",
|
||||
"input":"<!doc>\u0000",
|
||||
"output":[["Comment", "doc"], ["Character", "\u0000"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"U+0000 in lookahead region",
|
||||
"input":"<!doc\u0000",
|
||||
"output":[["Comment", "doc\uFFFD"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
|
||||
{ "code": "unexpected-null-character", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"U+0080 in lookahead region",
|
||||
"input":"<!doc\u0080",
|
||||
"output":[["Comment", "doc\u0080"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
|
||||
{ "code": "control-character-in-input-stream", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"U+FDD1 in lookahead region",
|
||||
"input":"<!doc\uFDD1",
|
||||
"output":[["Comment", "doc\uFDD1"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
|
||||
{ "code": "noncharacter-in-input-stream", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"U+1FFFF in lookahead region",
|
||||
"input":"<!doc\uD83F\uDFFF",
|
||||
"output":[["Comment", "doc\uD83F\uDFFF"]],
|
||||
"errors":[
|
||||
{ "code": "incorrectly-opened-comment", "line": 1, "col": 3 },
|
||||
{ "code": "noncharacter-in-input-stream", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"CR followed by non-LF",
|
||||
"input":"\r?",
|
||||
"output":[["Character", "\n?"]]},
|
||||
|
||||
{"description":"CR at EOF",
|
||||
"input":"\r",
|
||||
"output":[["Character", "\n"]]},
|
||||
|
||||
{"description":"LF at EOF",
|
||||
"input":"\n",
|
||||
"output":[["Character", "\n"]]},
|
||||
|
||||
{"description":"CR LF",
|
||||
"input":"\r\n",
|
||||
"output":[["Character", "\n"]]},
|
||||
|
||||
{"description":"CR CR",
|
||||
"input":"\r\r",
|
||||
"output":[["Character", "\n\n"]]},
|
||||
|
||||
{"description":"LF LF",
|
||||
"input":"\n\n",
|
||||
"output":[["Character", "\n\n"]]},
|
||||
|
||||
{"description":"LF CR",
|
||||
"input":"\n\r",
|
||||
"output":[["Character", "\n\n"]]},
|
||||
|
||||
{"description":"text CR CR CR text",
|
||||
"input":"text\r\r\rtext",
|
||||
"output":[["Character", "text\n\n\ntext"]]},
|
||||
|
||||
{"description":"Doctype publik",
|
||||
"input":"<!DOCTYPE html PUBLIK \"AbC\" \"XyZ\">",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype publi",
|
||||
"input":"<!DOCTYPE html PUBLI",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype sistem",
|
||||
"input":"<!DOCTYPE html SISTEM \"AbC\">",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype sys",
|
||||
"input":"<!DOCTYPE html SYS",
|
||||
"output":[["DOCTYPE", "html", null, null, false]],
|
||||
"errors":[
|
||||
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Doctype html x>text",
|
||||
"input":"<!DOCTYPE html x>text",
|
||||
"output":[["DOCTYPE", "html", null, null, false], ["Character", "text"]],
|
||||
"errors":[
|
||||
{ "code": "invalid-character-sequence-after-doctype-name", "line": 1, "col": 16 }
|
||||
]},
|
||||
|
||||
{"description":"Grave accent in unquoted attribute",
|
||||
"input":"<a a=aa`>",
|
||||
"output":[["StartTag", "a", {"a":"aa`"}]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-character-in-unquoted-attribute-value", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in tag name state ",
|
||||
"input":"<a",
|
||||
"output":[],
|
||||
"errors": [
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 3 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in before attribute name state",
|
||||
"input":"<a ",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 4 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in attribute name state",
|
||||
"input":"<a a",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 5 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in after attribute name state",
|
||||
"input":"<a a ",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 6 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in before attribute value state",
|
||||
"input":"<a a =",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 7 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in attribute value (double quoted) state",
|
||||
"input":"<a a =\"a",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in attribute value (single quoted) state",
|
||||
"input":"<a a ='a",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 9 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in attribute value (unquoted) state",
|
||||
"input":"<a a =a",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 8 }
|
||||
]},
|
||||
|
||||
{"description":"EOF in after attribute value state",
|
||||
"input":"<a a ='a'",
|
||||
"output":[],
|
||||
"errors":[
|
||||
{ "code": "eof-in-tag", "line": 1, "col": 10 }
|
||||
]}
|
||||
|
||||
]}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,41 @@
|
||||
{"tests" : [
|
||||
{"description": "Invalid Unicode character U+DFFF",
|
||||
"doubleEscaped":true,
|
||||
"input": "\\uDFFF",
|
||||
"output":[["Character", "\\uDFFF"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-in-input-stream", "line": 1, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description": "Invalid Unicode character U+D800",
|
||||
"doubleEscaped":true,
|
||||
"input": "\\uD800",
|
||||
"output":[["Character", "\\uD800"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-in-input-stream", "line": 1, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description": "Invalid Unicode character U+DFFF with valid preceding character",
|
||||
"doubleEscaped":true,
|
||||
"input": "a\\uDFFF",
|
||||
"output":[["Character", "a\\uDFFF"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-in-input-stream", "line": 1, "col": 2 }
|
||||
]},
|
||||
|
||||
{"description": "Invalid Unicode character U+D800 with valid following character",
|
||||
"doubleEscaped":true,
|
||||
"input": "\\uD800a",
|
||||
"output":[["Character", "\\uD800a"]],
|
||||
"errors":[
|
||||
{ "code": "surrogate-in-input-stream", "line": 1, "col": 1 }
|
||||
]},
|
||||
|
||||
{"description":"CR followed by U+0000",
|
||||
"input":"\r\u0000",
|
||||
"output":[["Character", "\n\u0000"]],
|
||||
"errors":[
|
||||
{ "code": "unexpected-null-character", "line": 2, "col": 1 }
|
||||
]}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{"xmlViolationTests": [
|
||||
|
||||
{"description":"Non-XML character",
|
||||
"input":"a\uFFFFb",
|
||||
"output":[["Character","a\uFFFDb"]]},
|
||||
|
||||
{"description":"Non-XML space",
|
||||
"input":"a\u000Cb",
|
||||
"output":[["Character","a b"]]},
|
||||
|
||||
{"description":"Double hyphen in comment",
|
||||
"input":"<!-- foo -- bar -->",
|
||||
"output":[["Comment"," foo - - bar "]]},
|
||||
|
||||
{"description":"FF between attributes",
|
||||
"input":"<a b=''\u000Cc=''>",
|
||||
"output":[["StartTag","a",{"b":"","c":""}]]}
|
||||
]}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ cargo build --release 2>&1 | grep -E "^(error|warning: unused)" || true
|
||||
echo "== test unitari"
|
||||
cargo test --quiet
|
||||
|
||||
echo "== conformità del tokenizer (corpus html5lib, lo stesso da cui WPT genera i suoi test)"
|
||||
cargo run --quiet --release --bin wpt -- --min 93
|
||||
|
||||
echo "== reftest"
|
||||
cargo run --quiet --bin reftest -- --cases cases
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Scarica il corpus `html5lib-tests/tokenizer`, lo stesso da cui il WPT genera i
|
||||
# propri test di parsing HTML. Senza questo, `wpt` (e quindi la CI) non ha niente
|
||||
# da misurare: il corpus è nel repository perché la CI deve essere deterministica
|
||||
# e non dipendere dalla rete, ma se serve rigenerarlo questo script lo rifà.
|
||||
#
|
||||
# Uso: scripts/scarica-corpus.sh [cartella]
|
||||
set -eu
|
||||
|
||||
DESTINAZIONE=${1:-cases/html5lib}
|
||||
BASE="https://raw.githubusercontent.com/html5lib/html5lib-tests/master/tokenizer"
|
||||
FILE="contentModelFlags domjs entities escapeFlag namedEntities numericEntities
|
||||
pendingSpecChanges test1 test2 test3 test4 unicodeChars
|
||||
unicodeCharsProblematic xmlViolation"
|
||||
|
||||
mkdir -p "$DESTINAZIONE"
|
||||
for nome in $FILE; do
|
||||
printf '%-28s ' "$nome"
|
||||
if curl -fsS --max-time 90 -o "$DESTINAZIONE/$nome.test" "$BASE/$nome.test"; then
|
||||
echo "ok"
|
||||
else
|
||||
echo "FALLITO"
|
||||
rm -f "$DESTINAZIONE/$nome.test"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "corpus in $DESTINAZIONE"
|
||||
@@ -0,0 +1,386 @@
|
||||
//! Conformità del tokenizer HTML contro il corpus `html5lib-tests`.
|
||||
//!
|
||||
//! Perché questo e non il WPT: i test di parsing del WPT sono pagine HTML che
|
||||
//! girano dentro `testharness.js` e hanno bisogno di `DOMParser`,
|
||||
//! `createHTMLDocument` e di un event loop con `async_test` — cose che il motore
|
||||
//! non ha. Il corpus `html5lib-tests/tokenizer` è invece **la sorgente** da cui
|
||||
//! WPT genera i propri test di parsing: misurarlo dà un numero vero, confrontabile,
|
||||
//! senza fingere di aver agganciato un harness che non c'è.
|
||||
//!
|
||||
//! Uso: `wpt [--min PERCENTUALE] [--verbose] [cartella]`
|
||||
//! Con `--min`, esce con codice 1 se la percentuale scende sotto la soglia: così
|
||||
//! la CI si accorge di una regressione.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
|
||||
use engine::tokenizer::{tokenize, Token};
|
||||
|
||||
#[derive(Default)]
|
||||
struct Esito {
|
||||
passati: usize,
|
||||
falliti: usize,
|
||||
saltati: usize,
|
||||
fallimenti: Vec<String>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut soglia: Option<f64> = None;
|
||||
let mut verboso = false;
|
||||
let mut cartella = String::from("cases/html5lib");
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(a) = args.next() {
|
||||
match a.as_str() {
|
||||
"--min" => soglia = args.next().and_then(|v| v.parse().ok()),
|
||||
"--verbose" | "-v" => verboso = true,
|
||||
altro => cartella = altro.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
let percorso = Path::new(&cartella);
|
||||
let mut file: Vec<_> = match std::fs::read_dir(percorso) {
|
||||
Ok(v) => v
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.path())
|
||||
.filter(|p| p.extension().map(|e| e == "test").unwrap_or(false))
|
||||
.collect(),
|
||||
Err(e) => {
|
||||
eprintln!("cartella {} illeggibile: {}", cartella, e);
|
||||
std::process::exit(2);
|
||||
}
|
||||
};
|
||||
file.sort();
|
||||
if file.is_empty() {
|
||||
eprintln!("nessun file .test in {}", cartella);
|
||||
std::process::exit(2);
|
||||
}
|
||||
|
||||
let mut totale = Esito::default();
|
||||
let mut per_file: Vec<(String, Esito)> = Vec::new();
|
||||
|
||||
for percorso_file in &file {
|
||||
let testo = match std::fs::read_to_string(percorso_file) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
eprintln!("{}: {}", percorso_file.display(), e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let mut esito = Esito::default();
|
||||
match serde_json::from_str::<serde_json::Value>(&testo) {
|
||||
Ok(json) => {
|
||||
if let Some(casi) = json.get("tests").and_then(|t| t.as_array()) {
|
||||
for caso in casi {
|
||||
esegui_caso(caso, &mut esito, verboso);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("{}: JSON illeggibile: {}", percorso_file.display(), e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
totale.passati += esito.passati;
|
||||
totale.falliti += esito.falliti;
|
||||
totale.saltati += esito.saltati;
|
||||
per_file.push((
|
||||
percorso_file
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_default(),
|
||||
esito,
|
||||
));
|
||||
}
|
||||
|
||||
println!(
|
||||
"{:<32} {:>6} {:>6} {:>6} {:>7}",
|
||||
"file", "passati", "falliti", "saltati", "esito"
|
||||
);
|
||||
for (nome, e) in &per_file {
|
||||
let fatti = e.passati + e.falliti;
|
||||
let pct = if fatti == 0 {
|
||||
0.0
|
||||
} else {
|
||||
100.0 * e.passati as f64 / fatti as f64
|
||||
};
|
||||
println!(
|
||||
"{:<32} {:>6} {:>6} {:>6} {:>6.1}%",
|
||||
nome, e.passati, e.falliti, e.saltati, pct
|
||||
);
|
||||
}
|
||||
|
||||
let fatti = totale.passati + totale.falliti;
|
||||
let pct = if fatti == 0 {
|
||||
0.0
|
||||
} else {
|
||||
100.0 * totale.passati as f64 / fatti as f64
|
||||
};
|
||||
println!(
|
||||
"\ntotale: {} passati, {} falliti, {} saltati — {:.2}% dei casi eseguibili",
|
||||
totale.passati, totale.falliti, totale.saltati, pct
|
||||
);
|
||||
|
||||
if let Some(minimo) = soglia {
|
||||
if pct + 1e-9 < minimo {
|
||||
eprintln!("conformità sotto la soglia: {:.2}% < {:.2}%", pct, minimo);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn esegui_caso(caso: &serde_json::Value, esito: &mut Esito, verboso: bool) {
|
||||
let descrizione = caso
|
||||
.get("description")
|
||||
.and_then(|d| d.as_str())
|
||||
.unwrap_or("(senza descrizione)");
|
||||
|
||||
// gli stati iniziali diversi da quello dei dati (RCDATA, CDATA, script, ...)
|
||||
// richiedono un tokenizer avviato a metà: fuori ambito, si dichiarano saltati
|
||||
if let Some(stati) = caso.get("initialStates").and_then(|s| s.as_array()) {
|
||||
if !stati.is_empty() {
|
||||
esito.saltati += 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// `lastStartTag` cambia il contesto (per esempio dentro un `<title>`): idem
|
||||
if caso.get("lastStartTag").is_some() {
|
||||
esito.saltati += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
let doppio = caso
|
||||
.get("doubleEscaped")
|
||||
.and_then(|d| d.as_bool())
|
||||
.unwrap_or(false);
|
||||
let decodifica = |s: &str| -> String {
|
||||
if doppio {
|
||||
decodifica_escape(s)
|
||||
} else {
|
||||
s.to_string()
|
||||
}
|
||||
};
|
||||
|
||||
let input = decodifica(caso.get("input").and_then(|i| i.as_str()).unwrap_or(""));
|
||||
let attesi = match caso.get("output").and_then(|o| o.as_array()) {
|
||||
Some(o) => o
|
||||
.iter()
|
||||
.filter_map(|t| token_atteso(t, doppio))
|
||||
.collect::<Vec<_>>(),
|
||||
None => {
|
||||
esito.saltati += 1;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let ottenuti: Vec<String> = tokenize(&input)
|
||||
.into_iter()
|
||||
.filter(|t| !matches!(t, Token::Eof))
|
||||
.map(descrivi)
|
||||
.collect();
|
||||
let attesi = unisci_caratteri(attesi);
|
||||
let ottenuti = unisci_caratteri(ottenuti);
|
||||
|
||||
if attesi == ottenuti {
|
||||
esito.passati += 1;
|
||||
} else {
|
||||
esito.falliti += 1;
|
||||
if verboso {
|
||||
esito.fallimenti.push(format!(
|
||||
"{}\n input: {:?}\n atteso: {:?}\n ottenuto: {:?}",
|
||||
descrizione, input, attesi, ottenuti
|
||||
));
|
||||
eprintln!("FALLITO: {}", esito.fallimenti.last().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Descrizione normalizzata di un token del corpus, nello stesso formato che
|
||||
/// usiamo per i nostri: così il confronto è fra stringhe.
|
||||
fn token_atteso(t: &serde_json::Value, doppio: bool) -> Option<String> {
|
||||
let elenco = t.as_array()?;
|
||||
let tipo = elenco.first()?.as_str()?;
|
||||
let dec = |v: Option<&serde_json::Value>| -> Option<String> {
|
||||
let s = v?.as_str()?;
|
||||
Some(if doppio {
|
||||
decodifica_escape(s)
|
||||
} else {
|
||||
s.to_string()
|
||||
})
|
||||
};
|
||||
match tipo {
|
||||
"DOCTYPE" => {
|
||||
let nome = elenco
|
||||
.get(1)
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.to_string());
|
||||
let pubblico = dec(elenco.get(2));
|
||||
let sistema = dec(elenco.get(3));
|
||||
let corretto = elenco.get(4).and_then(|v| v.as_bool()).unwrap_or(false);
|
||||
Some(format!(
|
||||
"DOCTYPE {:?} {:?} {:?} {}",
|
||||
nome, pubblico, sistema, corretto
|
||||
))
|
||||
}
|
||||
"StartTag" => {
|
||||
let nome = dec(elenco.get(1))?;
|
||||
let attributi = attributi_ordinati(elenco.get(2), doppio);
|
||||
let auto = elenco.get(3).and_then(|v| v.as_bool()).unwrap_or(false);
|
||||
Some(format!("StartTag {} [{}] {}", nome, attributi, auto))
|
||||
}
|
||||
"EndTag" => Some(format!("EndTag {}", dec(elenco.get(1))?)),
|
||||
"Comment" => Some(format!("Comment {:?}", dec(elenco.get(1))?)),
|
||||
"Character" => Some(format!("Character {:?}", dec(elenco.get(1))?)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn attributi_ordinati(v: Option<&serde_json::Value>, doppio: bool) -> String {
|
||||
let mut mappa: BTreeMap<String, String> = BTreeMap::new();
|
||||
if let Some(oggetto) = v.and_then(|v| v.as_object()) {
|
||||
for (nome, valore) in oggetto {
|
||||
let valore = valore.as_str().unwrap_or("");
|
||||
let valore = if doppio {
|
||||
decodifica_escape(valore)
|
||||
} else {
|
||||
valore.to_string()
|
||||
};
|
||||
mappa.insert(nome.clone(), valore);
|
||||
}
|
||||
}
|
||||
mappa
|
||||
.into_iter()
|
||||
.map(|(n, v)| format!("{}=\"{}\"", n, v))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
/// Descrizione di un token prodotto dal motore, nello stesso formato del corpus.
|
||||
fn descrivi(token: Token) -> String {
|
||||
match token {
|
||||
Token::StartTag {
|
||||
name,
|
||||
attrs,
|
||||
self_closing,
|
||||
} => {
|
||||
let mut mappa: BTreeMap<String, String> = BTreeMap::new();
|
||||
for (n, v) in attrs {
|
||||
mappa.insert(n, v);
|
||||
}
|
||||
let attributi = mappa
|
||||
.into_iter()
|
||||
.map(|(n, v)| format!("{}=\"{}\"", n, v))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
format!("StartTag {} [{}] {}", name, attributi, self_closing)
|
||||
}
|
||||
Token::EndTag { name } => format!("EndTag {}", name),
|
||||
Token::Text(testo) => format!("Character {:?}", testo),
|
||||
Token::Comment(testo) => format!("Comment {:?}", testo),
|
||||
Token::Doctype {
|
||||
name,
|
||||
public_id,
|
||||
system_id,
|
||||
corretto,
|
||||
} => format!(
|
||||
"DOCTYPE {:?} {:?} {:?} {}",
|
||||
name, public_id, system_id, corretto
|
||||
),
|
||||
Token::Eof => "EOF".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// I token di carattere consecutivi si confrontano come un testo solo: il corpus
|
||||
/// li spezza come capita, e anche noi emettiamo un testo per sequenza.
|
||||
fn unisci_caratteri(token: Vec<String>) -> Vec<String> {
|
||||
let mut out: Vec<String> = Vec::new();
|
||||
for t in token {
|
||||
if let Some(resto) = t.strip_prefix("Character ") {
|
||||
if let Some(ultimo) = out.last_mut() {
|
||||
if let Some(precedente) = ultimo.strip_prefix("Character ") {
|
||||
let mut a = testo_da_debug(precedente);
|
||||
a.push_str(&testo_da_debug(resto));
|
||||
*ultimo = format!("Character {:?}", a);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push(t);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Interpreta la forma `{:?}` di una stringa (virgolette e sequenze di escape)
|
||||
/// per poterle concatenare.
|
||||
fn testo_da_debug(s: &str) -> String {
|
||||
let senza_virgolette = s.trim_start_matches('"').trim_end_matches('"');
|
||||
let mut out = String::new();
|
||||
let mut iter = senza_virgolette.chars();
|
||||
while let Some(c) = iter.next() {
|
||||
if c != '\\' {
|
||||
out.push(c);
|
||||
continue;
|
||||
}
|
||||
match iter.next() {
|
||||
Some('n') => out.push('\n'),
|
||||
Some('r') => out.push('\r'),
|
||||
Some('t') => out.push('\t'),
|
||||
Some('"') => out.push('"'),
|
||||
Some('\\') => out.push('\\'),
|
||||
Some('u') => {
|
||||
// \u{XXXX}
|
||||
let mut cifre = String::new();
|
||||
for c in iter.by_ref() {
|
||||
if c == '}' {
|
||||
break;
|
||||
}
|
||||
if c != '{' {
|
||||
cifre.push(c);
|
||||
}
|
||||
}
|
||||
if let Ok(n) = u32::from_str_radix(&cifre, 16) {
|
||||
if let Some(c) = char::from_u32(n) {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(altro) => out.push(altro),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Le stringhe marcate `doubleEscaped` sono JSON annidate: `\uXXXX` diventa il
|
||||
/// carattere, e `\\` diventa `\`.
|
||||
fn decodifica_escape(s: &str) -> String {
|
||||
let mut out = String::new();
|
||||
let mut iter = s.chars().peekable();
|
||||
while let Some(c) = iter.next() {
|
||||
if c != '\\' {
|
||||
out.push(c);
|
||||
continue;
|
||||
}
|
||||
match iter.next() {
|
||||
Some('u') => {
|
||||
let mut cifre = String::new();
|
||||
for _ in 0..4 {
|
||||
if let Some(&c) = iter.peek() {
|
||||
cifre.push(c);
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
if let Ok(n) = u32::from_str_radix(&cifre, 16) {
|
||||
if let Some(c) = char::from_u32(n) {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some('n') => out.push('\n'),
|
||||
Some('t') => out.push('\t'),
|
||||
Some('r') => out.push('\r'),
|
||||
Some(altro) => out.push(altro),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,7 @@ pub mod bidi;
|
||||
pub mod cookie;
|
||||
pub mod css;
|
||||
pub mod dom;
|
||||
mod entita_tabelle;
|
||||
pub mod ffi;
|
||||
pub mod font;
|
||||
pub mod hpack_tabelle;
|
||||
|
||||
+30
-4
@@ -33,6 +33,7 @@ pub enum Cmd {
|
||||
data: Arc<ImageData>,
|
||||
dimensione: crate::style::DimensioneSfondo,
|
||||
ripeti: (bool, bool),
|
||||
posizione: (crate::style::Posizione, crate::style::Posizione),
|
||||
clip: Option<Rect>,
|
||||
},
|
||||
/// Sfondo a gradiente lineare, con il testo CSS originale.
|
||||
@@ -152,7 +153,7 @@ fn walk(
|
||||
let raggio = b.style.border_radius;
|
||||
|
||||
// comodo: applica ritaglio e opacità a un rettangolo
|
||||
let mut rett = |out: &mut Vec<Cmd>, rect: Rect, color: Color, radius: f32| {
|
||||
let rett = |out: &mut Vec<Cmd>, rect: Rect, color: Color, radius: f32| {
|
||||
let Some(rect) = applica_clip(rect, clip) else {
|
||||
return;
|
||||
};
|
||||
@@ -189,6 +190,7 @@ fn walk(
|
||||
data,
|
||||
dimensione: b.style.background_size,
|
||||
ripeti: b.style.background_repeat,
|
||||
posizione: b.style.background_position,
|
||||
clip,
|
||||
});
|
||||
}
|
||||
@@ -383,6 +385,7 @@ pub fn rasterize(cmds: &[Cmd], w: u32, h: u32, scale: f32) -> Vec<u8> {
|
||||
data,
|
||||
dimensione,
|
||||
ripeti,
|
||||
posizione,
|
||||
clip,
|
||||
} => {
|
||||
let ritaglio = clip.map(|c| (c.x * scale, c.y * scale, c.w * scale, c.h * scale));
|
||||
@@ -399,6 +402,7 @@ pub fn rasterize(cmds: &[Cmd], w: u32, h: u32, scale: f32) -> Vec<u8> {
|
||||
data,
|
||||
*dimensione,
|
||||
*ripeti,
|
||||
*posizione,
|
||||
scale,
|
||||
ritaglio,
|
||||
);
|
||||
@@ -1117,10 +1121,11 @@ fn disegna_sfondo(
|
||||
data: &ImageData,
|
||||
dimensione: crate::style::DimensioneSfondo,
|
||||
ripeti: (bool, bool),
|
||||
posizione: (crate::style::Posizione, crate::style::Posizione),
|
||||
scale: f32,
|
||||
ritaglio: Option<(f32, f32, f32, f32)>,
|
||||
) {
|
||||
use crate::style::DimensioneSfondo;
|
||||
use crate::style::{DimensioneSfondo, Posizione};
|
||||
if rect.w <= 0.0 || rect.h <= 0.0 || data.width == 0 || data.height == 0 {
|
||||
return;
|
||||
}
|
||||
@@ -1152,7 +1157,15 @@ fn disegna_sfondo(
|
||||
tw = tw.max(1.0);
|
||||
th = th.max(1.0);
|
||||
|
||||
let mut y = rect.y;
|
||||
// posizione del primo tassello: le percentuali valgono rispetto allo spazio
|
||||
// che avanza (box meno tassello), come nel CSS
|
||||
let offset = |p: Posizione, contenitore: f32, tassello: f32| -> f32 {
|
||||
match p {
|
||||
Posizione::Px(v) => v * scale,
|
||||
Posizione::Pct(v) => (contenitore - tassello) * v / 100.0,
|
||||
}
|
||||
};
|
||||
let mut y = rect.y + offset(posizione.1, rect.h, th);
|
||||
let mut riga = 0;
|
||||
// il tassello si disegna intero e a ritagliarlo pensa `draw_image_clippata`:
|
||||
// limitarlo al box lo schiaccerebbe invece di tagliarlo
|
||||
@@ -1160,8 +1173,21 @@ fn disegna_sfondo(
|
||||
Some((cx, cy, cw, ch)) => Some((cx, cy, cw, ch)),
|
||||
None => Some((rect.x, rect.y, rect.w, rect.h)),
|
||||
};
|
||||
// con `repeat`, il reticolo continua all'indietro fino a coprire il bordo:
|
||||
// un fondo posizionato a metà non lascia un vuoto a sinistra
|
||||
if ripeti.1 {
|
||||
while y > rect.y {
|
||||
y -= th;
|
||||
}
|
||||
}
|
||||
while y < rect.bottom() {
|
||||
let mut x = rect.x;
|
||||
let mut x0 = rect.x + offset(posizione.0, rect.w, tw);
|
||||
if ripeti.0 {
|
||||
while x0 > rect.x {
|
||||
x0 -= tw;
|
||||
}
|
||||
}
|
||||
let mut x = x0;
|
||||
let mut colonna = 0;
|
||||
while x < rect.right() {
|
||||
crate::img::draw_image_clippata(buf, w, h, (x, y, tw, th), data, clip);
|
||||
|
||||
@@ -88,6 +88,19 @@ pub enum Traccia {
|
||||
Auto,
|
||||
}
|
||||
|
||||
/// Una coordinata di `background-position`: px oppure percentuale del box.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum Posizione {
|
||||
Px(f32),
|
||||
Pct(f32),
|
||||
}
|
||||
|
||||
impl Default for Posizione {
|
||||
fn default() -> Self {
|
||||
Posizione::Pct(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// `background-size`: come si adatta l'immagine al box.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||
pub enum DimensioneSfondo {
|
||||
@@ -239,6 +252,8 @@ pub struct ComputedStyle {
|
||||
pub background_size: DimensioneSfondo,
|
||||
/// `background-repeat`: (orizzontale, verticale). `no-repeat` è (false, false)
|
||||
pub background_repeat: (bool, bool),
|
||||
/// `background-position`, orizzontale e verticale. Il valore iniziale è `0% 0%`
|
||||
pub background_position: (Posizione, Posizione),
|
||||
/// `background-image: linear-gradient(...)`, testo originale
|
||||
pub background_gradient: Option<String>,
|
||||
pub line_height: f32,
|
||||
@@ -312,6 +327,7 @@ impl Default for ComputedStyle {
|
||||
background_image: None,
|
||||
background_size: DimensioneSfondo::Auto,
|
||||
background_repeat: (true, true),
|
||||
background_position: (Posizione::Pct(0.0), Posizione::Pct(0.0)),
|
||||
background_gradient: None,
|
||||
line_height: 19.2,
|
||||
line_height_explicit: false,
|
||||
@@ -841,6 +857,40 @@ fn apply_declaration(st: &mut ComputedStyle, name: &str, value: &str, parent_fon
|
||||
}
|
||||
};
|
||||
}
|
||||
"background-position" => {
|
||||
let parti: Vec<&str> = v.split_whitespace().collect();
|
||||
let orizzontale = parti.first().copied().unwrap_or("0%");
|
||||
let verticale = parti.get(1).copied().unwrap_or_else(|| {
|
||||
// una sola parola: `center` vale per entrambi gli assi, un
|
||||
// valore orizzontale vale `center` in verticale
|
||||
if orizzontale.eq_ignore_ascii_case("center") {
|
||||
"center"
|
||||
} else {
|
||||
"center"
|
||||
}
|
||||
});
|
||||
let asse = |testo: &str, orizzontale: bool| -> Posizione {
|
||||
match testo.to_ascii_lowercase().as_str() {
|
||||
"left" => Posizione::Pct(0.0),
|
||||
"right" => Posizione::Pct(100.0),
|
||||
"top" => Posizione::Pct(0.0),
|
||||
"bottom" => Posizione::Pct(100.0),
|
||||
"center" => Posizione::Pct(50.0),
|
||||
altro => {
|
||||
if let Some(n) = altro.strip_suffix('%') {
|
||||
Posizione::Pct(n.trim().parse().unwrap_or(0.0))
|
||||
} else if let Some(l) = parse_len(altro, st.font_size) {
|
||||
Posizione::Px(l.resolve(st.font_size))
|
||||
} else {
|
||||
// parola non riconosciuta: resta il valore iniziale
|
||||
let _ = orizzontale;
|
||||
Posizione::Pct(0.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
st.background_position = (asse(orizzontale, true), asse(verticale, false));
|
||||
}
|
||||
"background-repeat" => {
|
||||
let minuscolo = v.trim().to_ascii_lowercase();
|
||||
st.background_repeat = match minuscolo.as_str() {
|
||||
|
||||
+196
-33
@@ -13,7 +13,14 @@ pub enum Token {
|
||||
},
|
||||
Text(String),
|
||||
Comment(String),
|
||||
Doctype,
|
||||
/// `<!doctype ...>`: nome e identificatori servono al confronto con la
|
||||
/// specifica; `corretto` è falso se durante la lettura c'è stato un errore
|
||||
Doctype {
|
||||
name: Option<String>,
|
||||
public_id: Option<String>,
|
||||
system_id: Option<String>,
|
||||
corretto: bool,
|
||||
},
|
||||
Eof,
|
||||
}
|
||||
|
||||
@@ -97,13 +104,33 @@ pub fn tokenize(input: &str) -> Vec<Token> {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Doctype o altra dichiarazione
|
||||
// Doctype o commento spurio. `<!` e `<?` non sono per forza una
|
||||
// dichiarazione: se non dicono `doctype` il contenuto è un commento
|
||||
// (è il caso di `<!>`, `<!ciao>`, `<! ` — molti casi del corpus).
|
||||
if b[i..].starts_with(&['<', '!']) || b[i..].starts_with(&['<', '?']) {
|
||||
let mut j = i + 2;
|
||||
let dopo = i + 2;
|
||||
let e_doctype = {
|
||||
let parola = "doctype";
|
||||
b.len() >= dopo + parola.len()
|
||||
&& b[dopo..dopo + parola.len()]
|
||||
.iter()
|
||||
.collect::<String>()
|
||||
.eq_ignore_ascii_case(parola)
|
||||
};
|
||||
if e_doctype {
|
||||
let (token, fine) = leggi_doctype(&b, dopo + "doctype".len());
|
||||
out.push(token);
|
||||
i = fine;
|
||||
continue;
|
||||
}
|
||||
// commento spurio: tutto quello che segue `<!` o `<?` fino a `>`
|
||||
let inizio = dopo;
|
||||
let mut j = inizio;
|
||||
while j < n && b[j] != '>' {
|
||||
j += 1;
|
||||
}
|
||||
out.push(Token::Doctype);
|
||||
let testo: String = b[inizio..j].iter().collect();
|
||||
out.push(Token::Comment(testo));
|
||||
i = (j + 1).min(n);
|
||||
continue;
|
||||
}
|
||||
@@ -160,6 +187,14 @@ pub fn tokenize(input: &str) -> Vec<Token> {
|
||||
while j < n && !b[j].is_whitespace() && b[j] != '=' && b[j] != '>' && b[j] != '/' {
|
||||
j += 1;
|
||||
}
|
||||
// Se il carattere non può iniziare un nome di attributo (per
|
||||
// esempio una `/` non seguita da `>`), si scarta e si prosegue:
|
||||
// senza questo il ciclo non avanza e il tokenizer si blocca.
|
||||
// È il caso di `<h/a='b'>`, che secondo la specifica vale `<h a='b'>`.
|
||||
if j == astart {
|
||||
j += 1;
|
||||
continue;
|
||||
}
|
||||
let aname: String = b[astart..j].iter().collect::<String>().to_ascii_lowercase();
|
||||
while j < n && b[j].is_whitespace() {
|
||||
j += 1;
|
||||
@@ -251,44 +286,80 @@ pub fn unescape(s: &str) -> String {
|
||||
let chars: Vec<char> = s.chars().collect();
|
||||
let mut i = 0;
|
||||
while i < chars.len() {
|
||||
if chars[i] == '&' {
|
||||
let mut j = i + 1;
|
||||
while j < chars.len() && j - i <= 10 && chars[j] != ';' {
|
||||
if chars[i] != '&' {
|
||||
out.push(chars[i]);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
// riferimento numerico: `&` oppure `&`
|
||||
if i + 1 < chars.len() && chars[i + 1] == '#' {
|
||||
let mut j = i + 2;
|
||||
let esadecimale = j < chars.len() && (chars[j] == 'x' || chars[j] == 'X');
|
||||
if esadecimale {
|
||||
j += 1;
|
||||
}
|
||||
if j < chars.len() && chars[j] == ';' {
|
||||
let ent: String = chars[i + 1..j].iter().collect();
|
||||
let rep = match ent.as_str() {
|
||||
"amp" => Some('&'),
|
||||
"lt" => Some('<'),
|
||||
"gt" => Some('>'),
|
||||
"quot" => Some('"'),
|
||||
"apos" => Some('\''),
|
||||
"nbsp" => Some('\u{00a0}'),
|
||||
_ => {
|
||||
if let Some(hex) = ent.strip_prefix("#x").or_else(|| ent.strip_prefix("#X"))
|
||||
{
|
||||
u32::from_str_radix(hex, 16).ok().and_then(char::from_u32)
|
||||
} else if let Some(dec) = ent.strip_prefix('#') {
|
||||
dec.parse::<u32>().ok().and_then(char::from_u32)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
if let Some(r) = rep {
|
||||
out.push(r);
|
||||
i = j + 1;
|
||||
continue;
|
||||
let inizio_cifre = j;
|
||||
while j < chars.len()
|
||||
&& if esadecimale {
|
||||
chars[j].is_ascii_hexdigit()
|
||||
} else {
|
||||
chars[j].is_ascii_digit()
|
||||
}
|
||||
{
|
||||
j += 1;
|
||||
}
|
||||
if j > inizio_cifre {
|
||||
let cifre: String = chars[inizio_cifre..j].iter().collect();
|
||||
let valore =
|
||||
u32::from_str_radix(&cifre, if esadecimale { 16 } else { 10 }).unwrap_or(0);
|
||||
// la specifica sostituisce i valori non validi con U+FFFD
|
||||
out.push(char::from_u32(valore).unwrap_or('\u{fffd}'));
|
||||
// il `;` dopo le cifre fa parte del riferimento e si consuma
|
||||
if j < chars.len() && chars[j] == ';' {
|
||||
j += 1;
|
||||
}
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// entità nominata: si prova la forma più lunga che esiste, con il punto
|
||||
// e virgola prima e senza poi (le forme senza `;` sono quelle "legacy")
|
||||
let massimo = (chars.len() - i - 1).min(32);
|
||||
let mut trovato: Option<(usize, &'static str)> = None;
|
||||
for lunghezza in (1..=massimo).rev() {
|
||||
let candidato: String = chars[i + 1..i + 1 + lunghezza].iter().collect();
|
||||
if let Some(caratteri) = cerca_entita(&candidato) {
|
||||
trovato = Some((lunghezza, caratteri));
|
||||
break;
|
||||
}
|
||||
// con il punto e virgola incluso nella lunghezza si è già provato;
|
||||
// le forme senza `;` esistono solo per 106 nomi, e la tabella le ha
|
||||
}
|
||||
match trovato {
|
||||
Some((lunghezza, caratteri)) => {
|
||||
out.push_str(caratteri);
|
||||
i += 1 + lunghezza;
|
||||
}
|
||||
None => {
|
||||
out.push('&');
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
out.push(chars[i]);
|
||||
i += 1;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Cerca un'entità nominata nella tabella (ricerca binaria). Il nome include il
|
||||
/// punto e virgola quando c'è: `amp;` e `amp` sono due voci distinte.
|
||||
fn cerca_entita(nome: &str) -> Option<&'static str> {
|
||||
use crate::entita_tabelle::ENTITA;
|
||||
match ENTITA.binary_search_by(|(n, _)| (*n).cmp(nome)) {
|
||||
Ok(posizione) => Some(ENTITA[posizione].1),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -333,3 +404,95 @@ mod tests {
|
||||
assert_eq!(joined, "ab");
|
||||
}
|
||||
}
|
||||
|
||||
/// Legge il resto di un `<!doctype …>`: nome, `PUBLIC`/`SYSTEM` e identificatori.
|
||||
/// `corretto` resta vero solo se la forma è quella della specifica, perché il
|
||||
/// corpus lo confronta (`<!DOCTYPEHtMl>` è un errore, `< !DOCTYPE html>` no).
|
||||
fn leggi_doctype(b: &[char], inizio: usize) -> (Token, usize) {
|
||||
let n = b.len();
|
||||
let mut j = inizio;
|
||||
let mut corretto = true;
|
||||
// deve esserci spazio (o direttamente `>`) dopo `doctype`
|
||||
if j >= n || !b[j].is_whitespace() {
|
||||
corretto = false;
|
||||
}
|
||||
while j < n && b[j].is_whitespace() {
|
||||
j += 1;
|
||||
}
|
||||
let inizio_nome = j;
|
||||
while j < n && !b[j].is_whitespace() && b[j] != '>' {
|
||||
j += 1;
|
||||
}
|
||||
let nome: String = b[inizio_nome..j]
|
||||
.iter()
|
||||
.collect::<String>()
|
||||
.to_ascii_lowercase();
|
||||
let name = if nome.is_empty() { None } else { Some(nome) };
|
||||
|
||||
let mut public_id: Option<String> = None;
|
||||
let mut system_id: Option<String> = None;
|
||||
|
||||
// leggi una stringa fra virgolette, se c'è
|
||||
let leggi_stringa = |j: &mut usize| -> Option<String> {
|
||||
while *j < n && b[*j].is_whitespace() {
|
||||
*j += 1;
|
||||
}
|
||||
if *j >= n || (b[*j] != '"' && b[*j] != '\'') {
|
||||
return None;
|
||||
}
|
||||
let virgoletta = b[*j];
|
||||
*j += 1;
|
||||
let start = *j;
|
||||
while *j < n && b[*j] != virgoletta && b[*j] != '>' {
|
||||
*j += 1;
|
||||
}
|
||||
let valore: String = b[start..*j].iter().collect();
|
||||
if *j < n && b[*j] == virgoletta {
|
||||
*j += 1;
|
||||
}
|
||||
Some(valore)
|
||||
};
|
||||
|
||||
while j < n && b[j].is_whitespace() {
|
||||
j += 1;
|
||||
}
|
||||
let parola = |j: usize, parola: &str| -> bool {
|
||||
b.len() >= j + parola.len()
|
||||
&& b[j..j + parola.len()]
|
||||
.iter()
|
||||
.collect::<String>()
|
||||
.eq_ignore_ascii_case(parola)
|
||||
};
|
||||
if parola(j, "public") {
|
||||
j += "public".len();
|
||||
public_id = leggi_stringa(&mut j);
|
||||
system_id = leggi_stringa(&mut j);
|
||||
} else if parola(j, "system") {
|
||||
j += "system".len();
|
||||
system_id = leggi_stringa(&mut j);
|
||||
}
|
||||
|
||||
while j < n && b[j] != '>' {
|
||||
// caratteri inattesi prima di `>`: errore, si salta
|
||||
corretto = false;
|
||||
j += 1;
|
||||
}
|
||||
if j < n && b[j] == '>' {
|
||||
j += 1;
|
||||
} else {
|
||||
// EOF dentro il doctype
|
||||
corretto = false;
|
||||
}
|
||||
if name.is_none() {
|
||||
corretto = false;
|
||||
}
|
||||
(
|
||||
Token::Doctype {
|
||||
name,
|
||||
public_id,
|
||||
system_id,
|
||||
corretto,
|
||||
},
|
||||
j,
|
||||
)
|
||||
}
|
||||
@@ -43,7 +43,7 @@ pub fn parse(html: &str) -> BuildResult {
|
||||
|
||||
match phase {
|
||||
Phase::BeforeHead => match tok {
|
||||
Token::Doctype | Token::Comment(_) | Token::Eof => {}
|
||||
Token::Doctype { .. } | Token::Comment(_) | Token::Eof => {}
|
||||
Token::Text(t) if t.trim().is_empty() => {}
|
||||
Token::StartTag { name, attrs, .. } if name == "html" => {
|
||||
let n = doc.create_element("html", attrs.clone());
|
||||
@@ -88,7 +88,7 @@ pub fn parse(html: &str) -> BuildResult {
|
||||
phase = Phase::InBody;
|
||||
reprocess = true;
|
||||
}
|
||||
Token::Comment(_) | Token::Doctype | Token::Eof => {}
|
||||
Token::Comment(_) | Token::Doctype { .. } | Token::Eof => {}
|
||||
Token::StartTag {
|
||||
name,
|
||||
attrs,
|
||||
@@ -126,7 +126,7 @@ pub fn parse(html: &str) -> BuildResult {
|
||||
},
|
||||
Phase::AfterHead => match tok {
|
||||
Token::Text(t) if t.trim().is_empty() => {}
|
||||
Token::Comment(_) | Token::Doctype | Token::Eof => {}
|
||||
Token::Comment(_) | Token::Doctype { .. } | Token::Eof => {}
|
||||
Token::StartTag { name, attrs, .. } if name == "body" => {
|
||||
let h = ensure_html(&mut doc, &mut stack, &mut html_node);
|
||||
let n = doc.create_element("body", attrs.clone());
|
||||
@@ -161,7 +161,7 @@ pub fn parse(html: &str) -> BuildResult {
|
||||
let n = doc.create_comment(c);
|
||||
doc.append_child(cur, n);
|
||||
}
|
||||
Token::Doctype | Token::Eof => {}
|
||||
Token::Doctype { .. } | Token::Eof => {}
|
||||
Token::StartTag {
|
||||
name,
|
||||
attrs,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: harbour-mosaic
|
||||
Summary: Mosaic browser with an independent rendering engine
|
||||
Version: 0.8.16
|
||||
Version: 0.8.17
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
License: MIT
|
||||
@@ -21,6 +21,16 @@ engine written from scratch (no WebKit, Blink, Gecko or Servo code).
|
||||
Milestone M0: HTML parsing, CSS cascade, block layout and CPU raster.
|
||||
|
||||
%changelog
|
||||
* Thu Nov 12 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.8.17-1
|
||||
- Conformita' del tokenizer misurata sul corpus html5lib: 93,88% (era il 48,42%
|
||||
al primo giro). Soglia 93% in CI
|
||||
- Corretto un BLOCCO del tokenizer su <h/a='b'>, <a/\0>, <z/0 <>: il ciclo
|
||||
degli attributi non avanzava mai
|
||||
- Ogni <!...> diventava un doctype: ora solo <!doctype e' un doctype, il resto
|
||||
e' un commento spurio (era il grosso dei fallimenti)
|
||||
- Entita' HTML nominate complete (2231 voci generate dal WHATWG)
|
||||
- DOCTYPE con nome, PUBLIC/SYSTEM e segnalazione degli errori
|
||||
|
||||
* Thu Nov 12 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.8.16-1
|
||||
- background-size (auto, cover, contain, misura) e background-repeat (repeat,
|
||||
repeat-x, repeat-y, no-repeat): gli sfondi non si stiracchiano piu' al box
|
||||
|
||||
Reference in new issue
Block a user