leptris 1.9.374.0-arm-linux → 1.9.376.0-arm-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +57 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/TODO.SOTA.md +154 -0
- data/vendor-src/libleptris/src/include/leptris.h +10 -0
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.c +126 -0
- data/vendor-src/libleptris/src/leptris/html/html_parse.c +370 -34
- data/vendor-src/libleptris/src/leptris/serialize/serialize.c +15 -43
- data/vendor-src/libleptris/test/html/test_html5lib.cpp +15 -5
- data/vendor-src/libleptris/test/parser/test_encoding.cpp +87 -0
- data/vendor-src/libleptris/test/serializer/test_serialize.cpp +65 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +2 -1
|
@@ -2767,6 +2767,9 @@ typedef struct {
|
|
|
2767
2767
|
* switch, so the divert stays armed. Re-armed by each
|
|
2768
2768
|
* </body>/</html> token. */
|
|
2769
2769
|
int after_body_done;
|
|
2770
|
+
/* Verdict bookkeeping only (never gates tree placement): the
|
|
2771
|
+
* AfterBody startTagOther error has fired for this phase. */
|
|
2772
|
+
int after_body_diag_done;
|
|
2770
2773
|
/* #659 two-mode split: leptris_parse_html_string is the WHATWG
|
|
2771
2774
|
* engine (full "in head" set: script/style/noscript/template
|
|
2772
2775
|
* ... lift into the implied head); the new
|
|
@@ -3299,6 +3302,53 @@ static int h_is_formatting(const char* n) {
|
|
|
3299
3302
|
return h_fmt4_lut[h_tag_id(n)];
|
|
3300
3303
|
}
|
|
3301
3304
|
|
|
3305
|
+
/* Raw-text tokenizer targets. In body they have no dedicated end-tag
|
|
3306
|
+
* handler: html5lib's endTagOther walks the stack and reports
|
|
3307
|
+
* unexpected-end-tag at the first special node, so every such token
|
|
3308
|
+
* reaching the generic walk is stray (the tokenizer consumes the
|
|
3309
|
+
* matching terminator when the element is actually open). */
|
|
3310
|
+
static int h_is_rawtext_name(const char* n) {
|
|
3311
|
+
return strcmp(n, "script") == 0 || strcmp(n, "style") == 0 ||
|
|
3312
|
+
strcmp(n, "title") == 0 || strcmp(n, "textarea") == 0 ||
|
|
3313
|
+
strcmp(n, "xmp") == 0 || strcmp(n, "iframe") == 0 ||
|
|
3314
|
+
strcmp(n, "noembed") == 0 || strcmp(n, "noframes") == 0;
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
/* html5lib generateImpliedEndTags set (§13.2.4.5): closing a block
|
|
3318
|
+
* or list item may pop these silently; anything else above the
|
|
3319
|
+
* target makes the close "too early". */
|
|
3320
|
+
static int h_is_implied_end_name(const char* n) {
|
|
3321
|
+
return strcmp(n, "p") == 0 || strcmp(n, "li") == 0 ||
|
|
3322
|
+
strcmp(n, "dd") == 0 || strcmp(n, "dt") == 0 ||
|
|
3323
|
+
strcmp(n, "option") == 0 || strcmp(n, "optgroup") == 0 ||
|
|
3324
|
+
strcmp(n, "rb") == 0 || strcmp(n, "rt") == 0 ||
|
|
3325
|
+
strcmp(n, "rtc") == 0 || strcmp(n, "rp") == 0;
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
/* End tags html5lib implements with endTagBlock / endTagListItem /
|
|
3329
|
+
* endTagAppletMarqueeObject — the handlers that raise
|
|
3330
|
+
* end-tag-too-early when the target is not the current node after
|
|
3331
|
+
* implied-end generation. */
|
|
3332
|
+
static int h_is_tooearly_target(const char* n) {
|
|
3333
|
+
return strcmp(n, "p") == 0 || strcmp(n, "li") == 0 ||
|
|
3334
|
+
strcmp(n, "dd") == 0 || strcmp(n, "dt") == 0 ||
|
|
3335
|
+
strcmp(n, "applet") == 0 || strcmp(n, "marquee") == 0 ||
|
|
3336
|
+
strcmp(n, "object") == 0 ||
|
|
3337
|
+
strcmp(n, "address") == 0 || strcmp(n, "article") == 0 ||
|
|
3338
|
+
strcmp(n, "aside") == 0 || strcmp(n, "blockquote") == 0 ||
|
|
3339
|
+
strcmp(n, "button") == 0 || strcmp(n, "center") == 0 ||
|
|
3340
|
+
strcmp(n, "details") == 0 || strcmp(n, "dialog") == 0 ||
|
|
3341
|
+
strcmp(n, "dir") == 0 || strcmp(n, "div") == 0 ||
|
|
3342
|
+
strcmp(n, "dl") == 0 || strcmp(n, "fieldset") == 0 ||
|
|
3343
|
+
strcmp(n, "figcaption") == 0 || strcmp(n, "figure") == 0 ||
|
|
3344
|
+
strcmp(n, "footer") == 0 || strcmp(n, "header") == 0 ||
|
|
3345
|
+
strcmp(n, "hgroup") == 0 || strcmp(n, "listing") == 0 ||
|
|
3346
|
+
strcmp(n, "main") == 0 || strcmp(n, "menu") == 0 ||
|
|
3347
|
+
strcmp(n, "nav") == 0 || strcmp(n, "ol") == 0 ||
|
|
3348
|
+
strcmp(n, "pre") == 0 || strcmp(n, "section") == 0 ||
|
|
3349
|
+
strcmp(n, "summary") == 0 || strcmp(n, "ul") == 0;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3302
3352
|
/* WHATWG "special" category (13.2.4.2) — the adoption agency's
|
|
3303
3353
|
* furthest-block candidates. */
|
|
3304
3354
|
/* Generated tag classifier (#1218 hot path): one first-char
|
|
@@ -4133,9 +4183,30 @@ static void h_append(HBuilder* b, LeptrisNodeRef n) {
|
|
|
4133
4183
|
b->open_ns[b->depth - 2] == H_NS_HTML &&
|
|
4134
4184
|
b->open_id[b->depth - 2] == h_id_table)
|
|
4135
4185
|
tbl_ctx = 1;
|
|
4186
|
+
/* InTable startTagInput with type=hidden: html5lib reports
|
|
4187
|
+
* unexpected-hidden-input-in-table and inserts AT the spot
|
|
4188
|
+
* (no fostering — h_fosterable exempts it, tests7:16-20). */
|
|
4189
|
+
if (b->whatwg_foster && tbl_ctx && b->input_hidden_tag &&
|
|
4190
|
+
leptris_node_get_type(n) == LEPTRIS_NODE_TYPE_ELEMENT &&
|
|
4191
|
+
h_tag_id(leptris_element_name((LeptrisElement)n)) ==
|
|
4192
|
+
h_id_input) {
|
|
4193
|
+
h_diag(b, "unexpected-hidden-input-in-table",
|
|
4194
|
+
b->err_line_memo_off,
|
|
4195
|
+
"hidden input inserted in table context");
|
|
4196
|
+
}
|
|
4136
4197
|
/* #659 foster (WHATWG only): text/elements in table context
|
|
4137
4198
|
* go before the nearest open table in ITS parent. */
|
|
4138
4199
|
if (b->whatwg_foster && tbl_ctx && h_fosterable(b, n)) {
|
|
4200
|
+
/* #1771: the corpus verdicts name the foster by node
|
|
4201
|
+
* kind (foster-parenting-character / -start-tag). The
|
|
4202
|
+
* position rides the line memo — h_append has no token
|
|
4203
|
+
* offset, and the verdict gate compares codes only. */
|
|
4204
|
+
h_diag(b,
|
|
4205
|
+
leptris_node_get_type(n) == LEPTRIS_NODE_TYPE_TEXT
|
|
4206
|
+
? "foster-parenting-character"
|
|
4207
|
+
: "foster-parenting-start-tag",
|
|
4208
|
+
b->err_line_memo_off,
|
|
4209
|
+
"node fostered out of the table context");
|
|
4139
4210
|
int ti = (int)b->depth - 1;
|
|
4140
4211
|
while (ti >= 0 && !h_ieq_raw(
|
|
4141
4212
|
leptris_element_name(b->open[ti]), "table"))
|
|
@@ -5841,6 +5912,13 @@ static LeptrisDocument html_parse_shared(
|
|
|
5841
5912
|
}
|
|
5842
5913
|
if (is_dt) {
|
|
5843
5914
|
q += 7;
|
|
5915
|
+
/* Tokenizer: need-space-after-doctype when the
|
|
5916
|
+
* keyword is not followed by whitespace
|
|
5917
|
+
* (doctype01:3, tests2:26-28). */
|
|
5918
|
+
if (b.whatwg && q < end && *q != '>' && !h_is_ws(*q))
|
|
5919
|
+
h_diag(&b, "need-space-after-doctype",
|
|
5920
|
+
(size_t)(q - b.input_base),
|
|
5921
|
+
"no space after <!doctype");
|
|
5844
5922
|
while (q < end && h_is_ws(*q)) q++;
|
|
5845
5923
|
const char* nstart = q;
|
|
5846
5924
|
while (q < end && !h_is_ws(*q) && *q != '>') q++;
|
|
@@ -5903,6 +5981,21 @@ static LeptrisDocument html_parse_shared(
|
|
|
5903
5981
|
* doctype - with an EMPTY name (13.2.5 "missing-
|
|
5904
5982
|
* doctype-name", doctype01.dat:4/5). WHATWG
|
|
5905
5983
|
* mode only; html4 keeps the drop. */
|
|
5984
|
+
/* #1771: html5lib's BeforeHtml processDoctype —
|
|
5985
|
+
* name != html, a public id, or a system id other
|
|
5986
|
+
* than about:legacy-compat is unknown-doctype. */
|
|
5987
|
+
if (b.whatwg) {
|
|
5988
|
+
size_t ln = nlen;
|
|
5989
|
+
int name_html = (ln == 4);
|
|
5990
|
+
for (int i = 0; name_html && i < 4; i++)
|
|
5991
|
+
if (h_lower(nstart[i]) != "html"[i])
|
|
5992
|
+
name_html = 0;
|
|
5993
|
+
if (!name_html || pub[0] ||
|
|
5994
|
+
(sys[0] && strcmp(sys, "about:legacy-compat") != 0))
|
|
5995
|
+
h_diag(&b, "unknown-doctype",
|
|
5996
|
+
(size_t)(nstart - b.input_base),
|
|
5997
|
+
"unknown DOCTYPE shape");
|
|
5998
|
+
}
|
|
5906
5999
|
if (nlen || b.whatwg) {
|
|
5907
6000
|
/* WHATWG lowercases the doctype name;
|
|
5908
6001
|
* libxml2 (the html4/parity mode) preserves
|
|
@@ -6166,6 +6259,27 @@ static LeptrisDocument html_parse_shared(
|
|
|
6166
6259
|
text = p;
|
|
6167
6260
|
continue;
|
|
6168
6261
|
}
|
|
6262
|
+
/* Stray raw-text end tag with no open stack: the raw-text
|
|
6263
|
+
* element completed during its start-tag handling, so this
|
|
6264
|
+
* token cannot close anything. html5lib's InHead/InBody
|
|
6265
|
+
* endTagOther reports unexpected-end-tag once the tree has
|
|
6266
|
+
* content (the synthesized body is the special node);
|
|
6267
|
+
* with nothing seen yet the phase errors differently and
|
|
6268
|
+
* the initial-mode checks above already cover it. */
|
|
6269
|
+
if (b.whatwg && nlen && b.depth == 0 && b.top_tail) {
|
|
6270
|
+
char rn[16];
|
|
6271
|
+
size_t rl = nlen < sizeof(rn) - 1 ? nlen : sizeof(rn) - 1;
|
|
6272
|
+
for (size_t i = 0; i < rl; i++) rn[i] = h_lower(ns[i]);
|
|
6273
|
+
rn[rl] = 0;
|
|
6274
|
+
if (h_is_rawtext_name(rn)) {
|
|
6275
|
+
h_diag(&b, "unexpected-end-tag",
|
|
6276
|
+
(size_t)(p - b.input_base),
|
|
6277
|
+
"</%s> has no matching open element", rn);
|
|
6278
|
+
p = q;
|
|
6279
|
+
text = p;
|
|
6280
|
+
continue;
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6169
6283
|
if (nlen && (b.depth > 0 ||
|
|
6170
6284
|
(b.whatwg &&
|
|
6171
6285
|
((nlen == 4 &&
|
|
@@ -6249,6 +6363,29 @@ static LeptrisDocument html_parse_shared(
|
|
|
6249
6363
|
const char* hn =
|
|
6250
6364
|
leptris_element_name(b.open[d - 1]);
|
|
6251
6365
|
if (hn && h_is_heading(hn)) {
|
|
6366
|
+
/* html5lib endTagHeading: after the
|
|
6367
|
+
* implied-end pass, a current
|
|
6368
|
+
* heading of a different name makes
|
|
6369
|
+
* the close too early (tests19:24:
|
|
6370
|
+
* </h2> over an open h3), and so
|
|
6371
|
+
* does a non-implied element above
|
|
6372
|
+
* the heading. */
|
|
6373
|
+
int early = strcmp(hn, lname) != 0;
|
|
6374
|
+
for (size_t k = d; k < b.depth; k++) {
|
|
6375
|
+
const char* an2 = leptris_element_name(
|
|
6376
|
+
b.open[k]);
|
|
6377
|
+
if (an2 &&
|
|
6378
|
+
b.open_ns[k] == H_NS_HTML &&
|
|
6379
|
+
!h_is_implied_end_name(an2)) {
|
|
6380
|
+
early = 1;
|
|
6381
|
+
break;
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
if (early)
|
|
6385
|
+
h_diag(&b, "end-tag-too-early",
|
|
6386
|
+
(size_t)(p - b.input_base),
|
|
6387
|
+
"</%s> closes <%s> early",
|
|
6388
|
+
lname, hn);
|
|
6252
6389
|
h_pop_to(&b, d - 1);
|
|
6253
6390
|
/* Old-suite rule (tests1:21/91):
|
|
6254
6391
|
* </table> also closes open
|
|
@@ -6289,6 +6426,12 @@ static LeptrisDocument html_parse_shared(
|
|
|
6289
6426
|
text = p;
|
|
6290
6427
|
continue;
|
|
6291
6428
|
}
|
|
6429
|
+
/* No heading in scope: html5lib still checks
|
|
6430
|
+
* the current node, which is never the token
|
|
6431
|
+
* (tests19:23: </h3> after <p>). */
|
|
6432
|
+
h_diag(&b, "end-tag-too-early",
|
|
6433
|
+
(size_t)(p - b.input_base),
|
|
6434
|
+
"</%s> with no open heading", lname);
|
|
6292
6435
|
}
|
|
6293
6436
|
/* #659 13.2.6.4.17: </p> with no p in button
|
|
6294
6437
|
* scope inserts an EMPTY <p> and closes it
|
|
@@ -6357,6 +6500,13 @@ static LeptrisDocument html_parse_shared(
|
|
|
6357
6500
|
strcmp(lname, "select") != 0 &&
|
|
6358
6501
|
|
|
6359
6502
|
strcmp(lname, "template") != 0) {
|
|
6503
|
+
/* #1771: html5lib's InSelect endTagOther
|
|
6504
|
+
* reports the drop (unexpected-end-tag-
|
|
6505
|
+
* in-select). */
|
|
6506
|
+
h_diag(&b, "unexpected-end-tag-in-select",
|
|
6507
|
+
(size_t)(p - b.input_base),
|
|
6508
|
+
"</%s> ignored inside <select>",
|
|
6509
|
+
lname);
|
|
6360
6510
|
p = q;
|
|
6361
6511
|
text = p;
|
|
6362
6512
|
continue;
|
|
@@ -6591,7 +6741,14 @@ static LeptrisDocument html_parse_shared(
|
|
|
6591
6741
|
strcmp(lname, "dd") == 0 ||
|
|
6592
6742
|
strcmp(lname, "dt") == 0) &&
|
|
6593
6743
|
(h_ieq_raw(on, "ul") ||
|
|
6594
|
-
h_ieq_raw(on, "ol")))
|
|
6744
|
+
h_ieq_raw(on, "ol"))) ||
|
|
6745
|
+
/* html5lib endTagOther: a
|
|
6746
|
+
* raw-text name has no
|
|
6747
|
+
* in-body handler, so the
|
|
6748
|
+
* walk errors at the first
|
|
6749
|
+
* special node. */
|
|
6750
|
+
(h_is_rawtext_name(lname) &&
|
|
6751
|
+
h_is_special_ww(on));
|
|
6595
6752
|
}
|
|
6596
6753
|
if (fenced) {
|
|
6597
6754
|
/* #1771: html5lib's walk reports
|
|
@@ -6645,6 +6802,27 @@ static LeptrisDocument html_parse_shared(
|
|
|
6645
6802
|
(int)(d - 1) <= ti)
|
|
6646
6803
|
break;
|
|
6647
6804
|
}
|
|
6805
|
+
/* html5lib endTagBlock / endTagListItem /
|
|
6806
|
+
* endTagAppletMarqueeObject: after the
|
|
6807
|
+
* implied-end pass, a non-implied element
|
|
6808
|
+
* above the target makes the close too
|
|
6809
|
+
* early (tests3:11: </pre> over <div>). */
|
|
6810
|
+
if (b.whatwg && b.open_ns[d - 1] == H_NS_HTML &&
|
|
6811
|
+
h_is_tooearly_target(lname)) {
|
|
6812
|
+
for (size_t k = d; k < b.depth; k++) {
|
|
6813
|
+
const char* an2 =
|
|
6814
|
+
leptris_element_name(b.open[k]);
|
|
6815
|
+
if (an2 &&
|
|
6816
|
+
b.open_ns[k] == H_NS_HTML &&
|
|
6817
|
+
!h_is_implied_end_name(an2)) {
|
|
6818
|
+
h_diag(&b, "end-tag-too-early",
|
|
6819
|
+
(size_t)(p - b.input_base),
|
|
6820
|
+
"</%s> closes over <%s>",
|
|
6821
|
+
lname, an2);
|
|
6822
|
+
break;
|
|
6823
|
+
}
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6648
6826
|
h_pop_to(&b, d - 1);
|
|
6649
6827
|
/* Old-suite </table> rule: closes
|
|
6650
6828
|
* formatting BELOW the table - only
|
|
@@ -6945,6 +7123,47 @@ static LeptrisDocument html_parse_shared(
|
|
|
6945
7123
|
while (q < end && !h_is_ws(*q) && *q != '>' && *q != '/') q++;
|
|
6946
7124
|
size_t nlen = (size_t)(q - ns);
|
|
6947
7125
|
char* name = h_pooled_lower(b.pool, ns, nlen);
|
|
7126
|
+
if (name && b.whatwg && strcmp(name, "html") != 0) {
|
|
7127
|
+
if (b.after_html &&
|
|
7128
|
+
!(b.frameset && strcmp(name, "noframes") == 0)) {
|
|
7129
|
+
/* AfterAfterBody / AfterAfterFrameset startTagOther
|
|
7130
|
+
* (only html — and noframes in the frameset flavor —
|
|
7131
|
+
* is accepted). */
|
|
7132
|
+
h_diag(&b, "expected-eof-but-got-start-tag",
|
|
7133
|
+
(size_t)(p - b.input_base),
|
|
7134
|
+
"<%s> after </html>", name);
|
|
7135
|
+
} else if (b.after_body && !b.after_body_done &&
|
|
7136
|
+
!b.frameset && !b.after_body_diag_done) {
|
|
7137
|
+
/* AfterBody startTagOther: the first non-html start
|
|
7138
|
+
* tag after </body> errors and moves the phase back
|
|
7139
|
+
* to in-body (tests15:4/6, tests9:21, tests10:20).
|
|
7140
|
+
* Bookkeeping is diagnostic-only: after_body_done
|
|
7141
|
+
* also gates comment placement. */
|
|
7142
|
+
h_diag(&b, "unexpected-start-tag-after-body",
|
|
7143
|
+
(size_t)(p - b.input_base),
|
|
7144
|
+
"<%s> after </body>", name);
|
|
7145
|
+
b.after_body_diag_done = 1;
|
|
7146
|
+
}
|
|
7147
|
+
/* AfterHead startTagFromHead: a head-only start tag in
|
|
7148
|
+
* the window after </head> and before body content is
|
|
7149
|
+
* processed in head but reported out-of-my-head
|
|
7150
|
+
* (tests7:3/4). */
|
|
7151
|
+
if (b.head_end_seen && !b.body_seen && !b.body_tag_seen &&
|
|
7152
|
+
!b.frameset && !b.after_body &&
|
|
7153
|
+
(strcmp(name, "base") == 0 ||
|
|
7154
|
+
strcmp(name, "basefont") == 0 ||
|
|
7155
|
+
strcmp(name, "bgsound") == 0 ||
|
|
7156
|
+
strcmp(name, "link") == 0 ||
|
|
7157
|
+
strcmp(name, "meta") == 0 ||
|
|
7158
|
+
strcmp(name, "noframes") == 0 ||
|
|
7159
|
+
strcmp(name, "script") == 0 ||
|
|
7160
|
+
strcmp(name, "style") == 0 ||
|
|
7161
|
+
strcmp(name, "title") == 0)) {
|
|
7162
|
+
h_diag(&b, "unexpected-start-tag-out-of-my-head",
|
|
7163
|
+
(size_t)(p - b.input_base),
|
|
7164
|
+
"<%s> after </head>", name);
|
|
7165
|
+
}
|
|
7166
|
+
}
|
|
6948
7167
|
if (!name) goto done;
|
|
6949
7168
|
/* #659 (13.2.6.4.7): <image> is renamed <img> and
|
|
6950
7169
|
* reprocessed (tests1:90). */
|
|
@@ -7038,6 +7257,13 @@ static LeptrisDocument html_parse_shared(
|
|
|
7038
7257
|
if (t) h_append(&b, (LeptrisNodeRef)t);
|
|
7039
7258
|
}
|
|
7040
7259
|
if (strcmp(name, "body") == 0) {
|
|
7260
|
+
/* InBody startTagBody always reports
|
|
7261
|
+
* unexpected-start-tag for a second <body>
|
|
7262
|
+
* (tests2:16); the first one is the phase entry. */
|
|
7263
|
+
if (b.whatwg && (b.body_tag_seen || b.body_seen))
|
|
7264
|
+
h_diag(&b, "unexpected-start-tag",
|
|
7265
|
+
(size_t)(p - b.input_base),
|
|
7266
|
+
"<body> after the body exists");
|
|
7041
7267
|
b.body_tag_seen = 1;
|
|
7042
7268
|
if (b.whatwg) b.frameset_ok = 0;
|
|
7043
7269
|
/* Only the FIRST structural <body> marks the
|
|
@@ -7049,6 +7275,15 @@ static LeptrisDocument html_parse_shared(
|
|
|
7049
7275
|
b.lift_boundary = b.top_tail;
|
|
7050
7276
|
}
|
|
7051
7277
|
} else {
|
|
7278
|
+
/* InBody/AfterHead startTagHead: any <head> after
|
|
7279
|
+
* the head phase started is an unexpected start tag
|
|
7280
|
+
* (tests6:1: </head> <head>). */
|
|
7281
|
+
if (b.whatwg &&
|
|
7282
|
+
(b.head_tag_seen || b.head_end_seen ||
|
|
7283
|
+
b.body_tag_seen || b.body_seen))
|
|
7284
|
+
h_diag(&b, "unexpected-start-tag",
|
|
7285
|
+
(size_t)(p - b.input_base),
|
|
7286
|
+
"<head> after the head phase");
|
|
7052
7287
|
/* Before-head ends here: later comments are head
|
|
7053
7288
|
* content; earlier ones stay html-prefix children. */
|
|
7054
7289
|
b.head_tag_seen = 1;
|
|
@@ -7077,18 +7312,18 @@ static LeptrisDocument html_parse_shared(
|
|
|
7077
7312
|
/* frameset is NOT in the 13.2.6.5 breakout list: inside
|
|
7078
7313
|
* foreign content it is a plain foreign element
|
|
7079
7314
|
* (plain-text-unsafe:16-23). */
|
|
7080
|
-
/* #1771: html5lib's
|
|
7081
|
-
*
|
|
7082
|
-
*
|
|
7083
|
-
* ignored
|
|
7084
|
-
*
|
|
7085
|
-
*
|
|
7086
|
-
*
|
|
7087
|
-
if (b.
|
|
7315
|
+
/* #1771: html5lib's InBody startTagFrameset always
|
|
7316
|
+
* reports unexpected-start-tag — the frameset either
|
|
7317
|
+
* converts (body element absent, frameset-ok set) or is
|
|
7318
|
+
* ignored. frameset_ok==0 marks the InBody phase: any
|
|
7319
|
+
* body tag/content (or a frameset-ok-clearing start)
|
|
7320
|
+
* has already been seen. AfterHead converters keep
|
|
7321
|
+
* frameset_ok==1 and stay clean (webkit01:51). */
|
|
7322
|
+
if (!b.frameset_ok && !b.frameset &&
|
|
7088
7323
|
h_template_idx(&b) < 0)
|
|
7089
7324
|
h_diag(&b, "unexpected-start-tag",
|
|
7090
7325
|
(size_t)(p - b.input_base),
|
|
7091
|
-
"frameset
|
|
7326
|
+
"frameset in the body phase");
|
|
7092
7327
|
/* depth<=1: at most the (explicit or synthesized) html
|
|
7093
7328
|
* element is open; frameset-ok is the spec gate and the
|
|
7094
7329
|
* body is removed wholesale when it converts. */
|
|
@@ -7163,6 +7398,20 @@ static LeptrisDocument html_parse_shared(
|
|
|
7163
7398
|
strcmp(name, "frame") != 0 &&
|
|
7164
7399
|
strcmp(name, "noframes") != 0 &&
|
|
7165
7400
|
strcmp(name, "html") != 0) {
|
|
7401
|
+
/* html5lib phase verdicts for the dropped token (the
|
|
7402
|
+
* after-</html> flavor is emitted at the start-tag
|
|
7403
|
+
* dispatch): AfterFrameset names its own code; inside an
|
|
7404
|
+
* open frameset it is InFrameset's. */
|
|
7405
|
+
if (!b.after_html) {
|
|
7406
|
+
if (b.after_frameset)
|
|
7407
|
+
h_diag(&b, "unexpected-start-tag-after-frameset",
|
|
7408
|
+
(size_t)(p - b.input_base),
|
|
7409
|
+
"<%s> after </frameset>", name);
|
|
7410
|
+
else
|
|
7411
|
+
h_diag(&b, "unexpected-start-tag-in-frameset",
|
|
7412
|
+
(size_t)(p - b.input_base),
|
|
7413
|
+
"<%s> inside <frameset>", name);
|
|
7414
|
+
}
|
|
7166
7415
|
if (text < p) {
|
|
7167
7416
|
LeptrisTextNode* t = h_text_node(&b, text, p);
|
|
7168
7417
|
if (t) {
|
|
@@ -7215,7 +7464,11 @@ static LeptrisDocument html_parse_shared(
|
|
|
7215
7464
|
if (b.whatwg && h_in_select(&b) &&
|
|
7216
7465
|
strcmp(name, "select") == 0) {
|
|
7217
7466
|
/* 13.2.6.4.11: a <select> start tag inside a select
|
|
7218
|
-
* ACTS AS its end tag — no nesting (tests1:30).
|
|
7467
|
+
* ACTS AS its end tag — no nesting (tests1:30).
|
|
7468
|
+
* #1771: html5lib reports unexpected-select-in-select. */
|
|
7469
|
+
h_diag(&b, "unexpected-select-in-select",
|
|
7470
|
+
(size_t)(p - b.input_base),
|
|
7471
|
+
"<select> inside <select> acts as an end tag");
|
|
7219
7472
|
for (size_t d2 = b.depth; d2 > 0; d2--)
|
|
7220
7473
|
if (strcmp(leptris_element_name(b.open[d2 - 1]),
|
|
7221
7474
|
"select") == 0) {
|
|
@@ -7274,6 +7527,11 @@ static LeptrisDocument html_parse_shared(
|
|
|
7274
7527
|
b.depth = (size_t)sel_idx; /* pop the select;
|
|
7275
7528
|
* reprocess below */
|
|
7276
7529
|
} else {
|
|
7530
|
+
/* #1771: html5lib's InSelect startTagOther reports
|
|
7531
|
+
* the drop (unexpected-start-tag-in-select). */
|
|
7532
|
+
h_diag(&b, "unexpected-start-tag-in-select",
|
|
7533
|
+
(size_t)(p - b.input_base),
|
|
7534
|
+
"<%s> ignored inside <select>", name);
|
|
7277
7535
|
while (q < end && *q != '>') q++;
|
|
7278
7536
|
p = (q < end) ? q + 1 : end;
|
|
7279
7537
|
text = p;
|
|
@@ -7288,6 +7546,12 @@ static LeptrisDocument html_parse_shared(
|
|
|
7288
7546
|
(strcmp(name, "input") == 0 ||
|
|
7289
7547
|
strcmp(name, "keygen") == 0 ||
|
|
7290
7548
|
strcmp(name, "textarea") == 0)) {
|
|
7549
|
+
/* InSelect startTagInput (shared by input/keygen/
|
|
7550
|
+
* textarea) reports before popping the select
|
|
7551
|
+
* (tests7:14). */
|
|
7552
|
+
h_diag(&b, "unexpected-input-in-select",
|
|
7553
|
+
(size_t)(p - b.input_base),
|
|
7554
|
+
"<%s> inside <select>", name);
|
|
7291
7555
|
for (size_t d2 = b.depth; d2 > 0; d2--)
|
|
7292
7556
|
if (strcmp(leptris_element_name(b.open[d2 - 1]),
|
|
7293
7557
|
"select") == 0) {
|
|
@@ -7342,6 +7606,17 @@ static LeptrisDocument html_parse_shared(
|
|
|
7342
7606
|
continue;
|
|
7343
7607
|
}
|
|
7344
7608
|
|
|
7609
|
+
/* html5lib startTagHtml: an <html> token processed once the
|
|
7610
|
+
* html/head/body phases exist is not the first start tag —
|
|
7611
|
+
* parse error non-html-root, then the attributes merge onto
|
|
7612
|
+
* the root (tests14:3/4/6, tests19:37/38/88, tests2:52-54). */
|
|
7613
|
+
if (b.whatwg && strcmp(name, "html") == 0 &&
|
|
7614
|
+
(b.html_seen || b.head_tag_seen || b.body_tag_seen ||
|
|
7615
|
+
b.after_body || b.body_seen)) {
|
|
7616
|
+
h_diag(&b, "non-html-root",
|
|
7617
|
+
(size_t)(p - b.input_base),
|
|
7618
|
+
"<html> after the root element exists");
|
|
7619
|
+
}
|
|
7345
7620
|
/* 13.2.6.3: an <html> start tag inside content (never
|
|
7346
7621
|
* seen yet, deep in a table/foreign subtree) merges attrs
|
|
7347
7622
|
* and is ignored - no element (domjs-unsafe:36:
|
|
@@ -7461,7 +7736,13 @@ static LeptrisDocument html_parse_shared(
|
|
|
7461
7736
|
if (h_is_breakout(name) ||
|
|
7462
7737
|
(strcmp(name, "font") == 0 && h_font_break(q, end))) {
|
|
7463
7738
|
/* Breakout: pop the foreign scope, reprocess
|
|
7464
|
-
* under HTML rules below.
|
|
7739
|
+
* under HTML rules below. html5lib's foreign
|
|
7740
|
+
* startTagOther reports the HTML element as
|
|
7741
|
+
* unexpected in foreign content
|
|
7742
|
+
* (tests9:15, tests10:14). */
|
|
7743
|
+
h_diag(&b, "unexpected-html-element-in-foreign-content",
|
|
7744
|
+
(size_t)(p - b.input_base),
|
|
7745
|
+
"<%s> breaks out of foreign content", name);
|
|
7465
7746
|
while (b.depth > 0 &&
|
|
7466
7747
|
b.open_ns[b.depth - 1] != H_NS_HTML &&
|
|
7467
7748
|
!h_is_int_point(&b, b.depth - 1))
|
|
@@ -7479,6 +7760,12 @@ static LeptrisDocument html_parse_shared(
|
|
|
7479
7760
|
/* Implied end tags this start tag triggers (HTML rules
|
|
7480
7761
|
* only — foreign content has none). */
|
|
7481
7762
|
if (elem_ns == H_NS_HTML) {
|
|
7763
|
+
/* html5lib startTagListItem/startTagBlock: an implied
|
|
7764
|
+
* close whose target is buried under a non-implied
|
|
7765
|
+
* element (div, article, ...) reports end-tag-too-early
|
|
7766
|
+
* on this START tag (tests2:11, tests3:20). One per
|
|
7767
|
+
* token, like the reference walk. */
|
|
7768
|
+
const char* implied_early = NULL;
|
|
7482
7769
|
/* WHATWG: a dd/dt start closes the NEAREST open dd/dt
|
|
7483
7770
|
* in default scope — sibling definition items even
|
|
7484
7771
|
* with content in between (13.2.6.4.7, tests19:30:
|
|
@@ -7488,6 +7775,15 @@ static LeptrisDocument html_parse_shared(
|
|
|
7488
7775
|
for (size_t d = b.depth; d > 0; d--) {
|
|
7489
7776
|
uint8_t oid = b.open_id[d - 1];
|
|
7490
7777
|
if (oid == h_id_dd || oid == h_id_dt) {
|
|
7778
|
+
for (size_t k = d; k < b.depth; k++) {
|
|
7779
|
+
const char* an2 =
|
|
7780
|
+
leptris_element_name(b.open[k]);
|
|
7781
|
+
if (an2 && b.open_ns[k] == H_NS_HTML &&
|
|
7782
|
+
!h_is_implied_end_name(an2)) {
|
|
7783
|
+
implied_early = an2;
|
|
7784
|
+
break;
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7491
7787
|
b.depth = d - 1;
|
|
7492
7788
|
break;
|
|
7493
7789
|
}
|
|
@@ -7509,6 +7805,17 @@ static LeptrisDocument html_parse_shared(
|
|
|
7509
7805
|
if ((tid == h_id_li && oid == h_id_li) ||
|
|
7510
7806
|
(tid != h_id_li &&
|
|
7511
7807
|
(oid == h_id_dd || oid == h_id_dt))) {
|
|
7808
|
+
if (!implied_early) {
|
|
7809
|
+
for (size_t k = d; k < b.depth; k++) {
|
|
7810
|
+
const char* an2 =
|
|
7811
|
+
leptris_element_name(b.open[k]);
|
|
7812
|
+
if (an2 && b.open_ns[k] == H_NS_HTML &&
|
|
7813
|
+
!h_is_implied_end_name(an2)) {
|
|
7814
|
+
implied_early = an2;
|
|
7815
|
+
break;
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7818
|
+
}
|
|
7512
7819
|
b.depth = d - 1;
|
|
7513
7820
|
break;
|
|
7514
7821
|
}
|
|
@@ -7529,6 +7836,17 @@ static LeptrisDocument html_parse_shared(
|
|
|
7529
7836
|
for (size_t d = b.depth; d > 0; d--) {
|
|
7530
7837
|
uint8_t oid = b.open_id[d - 1];
|
|
7531
7838
|
if (oid == h_id_p) {
|
|
7839
|
+
if (!implied_early) {
|
|
7840
|
+
for (size_t k = d; k < b.depth; k++) {
|
|
7841
|
+
const char* an2 =
|
|
7842
|
+
leptris_element_name(b.open[k]);
|
|
7843
|
+
if (an2 && b.open_ns[k] == H_NS_HTML &&
|
|
7844
|
+
!h_is_implied_end_name(an2)) {
|
|
7845
|
+
implied_early = an2;
|
|
7846
|
+
break;
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
}
|
|
7532
7850
|
b.depth = d - 1;
|
|
7533
7851
|
break;
|
|
7534
7852
|
}
|
|
@@ -7537,6 +7855,10 @@ static LeptrisDocument html_parse_shared(
|
|
|
7537
7855
|
break;
|
|
7538
7856
|
}
|
|
7539
7857
|
}
|
|
7858
|
+
if (b.whatwg && implied_early)
|
|
7859
|
+
h_diag(&b, "end-tag-too-early",
|
|
7860
|
+
(size_t)(p - b.input_base),
|
|
7861
|
+
"implied close crosses <%s>", implied_early);
|
|
7540
7862
|
uint8_t tmpl_last_popped = H_ID_UNKNOWN;
|
|
7541
7863
|
while (b.depth > 0) {
|
|
7542
7864
|
uint8_t oid = b.open_id[b.depth - 1];
|
|
@@ -8323,29 +8645,43 @@ done:
|
|
|
8323
8645
|
/* Nothing appended (empty input, stray end tags only, doctype
|
|
8324
8646
|
* only) is NOT an error in lenient HTML mode: the wrapper
|
|
8325
8647
|
* synthesis below yields the empty Nokogiri shape. */
|
|
8326
|
-
/* #1771:
|
|
8327
|
-
* expected-closing-tag-but-got-eof
|
|
8328
|
-
*
|
|
8329
|
-
*
|
|
8330
|
-
*
|
|
8331
|
-
*
|
|
8332
|
-
*
|
|
8333
|
-
*
|
|
8334
|
-
*
|
|
8335
|
-
*
|
|
8648
|
+
/* #1771: html5lib's InBody processEOF (html5parser.py:958):
|
|
8649
|
+
* ONE expected-closing-tag-but-got-eof iff ANY open element is
|
|
8650
|
+
* outside the allowed set {dd,dt,li,p,tbody,td,tfoot,th,thead,
|
|
8651
|
+
* tr,body,html} — li/p/table scaffolding does not count
|
|
8652
|
+
* (tests1:34), address/applet/div do (blocks.dat:1,
|
|
8653
|
+
* tests20:96-class). AfterBody's processEOF is silent
|
|
8654
|
+
* (html5parser.py:2533) and its non-wsCharacters rule flips the
|
|
8655
|
+
* phase back to in-body — the builder's after_body/after_body_done
|
|
8656
|
+
* pair is exactly that state. A raw-text container got its own
|
|
8657
|
+
* variant at the raw branch already (that branch pops the
|
|
8658
|
+
* element). Judged BEFORE the wrapper synthesis tears the open
|
|
8659
|
+
* stack down. */
|
|
8336
8660
|
if (b.whatwg && b.depth > 0) {
|
|
8337
|
-
uint8_t
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8661
|
+
static uint8_t k_allowed[256];
|
|
8662
|
+
static int allowed_init;
|
|
8663
|
+
if (!allowed_init) {
|
|
8664
|
+
/* id tables are lazily initialized once; these ids are
|
|
8665
|
+
* stable for the process lifetime */
|
|
8666
|
+
uint8_t ids[] = {h_id_p, h_id_li, h_id_dd, h_id_dt,
|
|
8667
|
+
h_id_tbody, h_id_td, h_id_tfoot,
|
|
8668
|
+
h_id_th, h_id_thead, h_id_tr,
|
|
8669
|
+
h_id_body, h_id_html};
|
|
8670
|
+
for (size_t k = 0; k < sizeof(ids) / sizeof(ids[0]); k++)
|
|
8671
|
+
k_allowed[ids[k]] = 1;
|
|
8672
|
+
allowed_init = 1;
|
|
8673
|
+
}
|
|
8674
|
+
for (size_t k = 0; k < b.depth; k++) {
|
|
8675
|
+
uint8_t id = b.open_id[k];
|
|
8676
|
+
if (id == h_id_html || id == h_id_head || id == h_id_body)
|
|
8677
|
+
continue;
|
|
8678
|
+
if (!k_allowed[id]) {
|
|
8679
|
+
h_diag(&b, "expected-closing-tag-but-got-eof",
|
|
8680
|
+
b.input_len,
|
|
8681
|
+
"elements left open at end of input");
|
|
8682
|
+
break;
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8349
8685
|
}
|
|
8350
8686
|
/* Nokogiri document shape (#659): with no explicit <html>,
|
|
8351
8687
|
* synthesize <html><head></head><body>content</body></html> —
|