leptris 1.9.428.0 → 1.9.429.0
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/vendor/aarch64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +9 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/rng/validate.c +136 -44
- data/vendor-src/libleptris/test/fuzz/corpus/html_tree_amplification_timeout.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_html_seeds.py +101 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xpath_seeds.py +123 -0
- data/vendor-src/libleptris/test/rng/test_rng.cpp +47 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be08e6e08742584fcc0523bf76478c5a5978b9bd53a6169d13e6f4e7eab5a4c1
|
|
4
|
+
data.tar.gz: 4f4b0061724dccd35e8b2bccb74578183a380ffec6d6cda8188cd65c5e43883b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e43dae55cc12500816a1f3481e5d3067e5c9647641e1c7be741de4af2f6697066238e6701cca34810a52d80220183a8221d7fe680a4e9730980dd061b0e7da79
|
|
7
|
+
data.tar.gz: 34cbe840aeb0877fbab52973712b9eaa993198ead5fd5b6825c3356312d9fb8f463baabae7b5d70e93196250ac67a61b4572edc8fb6951219a3072ac50e78210
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.429"
|
|
12
12
|
|
|
13
13
|
# THE SSOT for the per-minor native bundle list (ruby#645): one line,
|
|
14
14
|
# space-separated, consumed by the Rakefile, the per-minor builder's
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/leptris/version.rb
CHANGED
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.429] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **RELAX NG regression (1.9.428.0)**: `combine="interleave"` merges no longer interleaved the added pattern INTO a base sequence — the added element could not sit between two base elements (RELAX NG §4.17; ruby#650). The interleave walk is now a per-branch cursor machine with full backtracking (branches match non-contiguously; repeatable members hold their cursor and may match again after another branch consumes; the search returns the furthest completion with a step budget for pathological documents). Within-a-body order still holds, per Jing. leptris#2094.
|
|
8
|
+
- Fuzz tooling: gen_xpath_seeds emits per-file corpus entries (the nightly's XPath leg takes corpus directories).
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
## [1.9.428] - 2026-11-18
|
|
4
13
|
|
|
5
14
|
### Fixed
|
|
@@ -602,6 +602,119 @@ static size_t fold_list(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
|
602
602
|
static size_t match_seq(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
603
603
|
size_t n, size_t idx);
|
|
604
604
|
|
|
605
|
+
/* The interleave matcher (ruby#650): branches match NON-contiguously
|
|
606
|
+
* — that is what interleaving IS — so a window matcher is wrong (a
|
|
607
|
+
* group(base) branch fails atomically at the frontier even though its
|
|
608
|
+
* second element matches two positions later, after another branch
|
|
609
|
+
* consumes there). Each branch carries a CURSOR into its own child
|
|
610
|
+
* chain; the search advances one branch's head pattern at the shared
|
|
611
|
+
* frontier, recurses, and backtracks on overall failure. Jing does
|
|
612
|
+
* the same search over its interleave automaton. */
|
|
613
|
+
typedef struct {
|
|
614
|
+
RngPattern* cur[64]; /* the branch's remaining member pattern */
|
|
615
|
+
int unit[64]; /* the branch is a single non-group pattern */
|
|
616
|
+
int done[64]; /* the branch fully matched */
|
|
617
|
+
size_t cn;
|
|
618
|
+
unsigned long steps; /* search budget: invalid documents explode
|
|
619
|
+
combinatorially under full enumeration;
|
|
620
|
+
past the budget the match fails
|
|
621
|
+
conservatively (the diagnose pass then
|
|
622
|
+
reports the shortfall) */
|
|
623
|
+
} IlvState;
|
|
624
|
+
|
|
625
|
+
static size_t rng_interleave_try(RngVal* v, IlvState* st,
|
|
626
|
+
LeptrisNodeRef* kids, size_t n,
|
|
627
|
+
size_t i, unsigned held_mask);
|
|
628
|
+
|
|
629
|
+
/* Advance (or hold) branch b after its head matched r. A REPEATABLE
|
|
630
|
+
* member that CONSUMED stays on its cursor — it may match again after
|
|
631
|
+
* another branch consumes at the frontier (ruby#650: ics on both
|
|
632
|
+
* sides of the merged-in element). */
|
|
633
|
+
static void ilv_advance(IlvState* st, size_t b, RngPattern* h,
|
|
634
|
+
size_t r, size_t i) {
|
|
635
|
+
int repeatable = (h->kind == RNG_ZERO_OR_MORE ||
|
|
636
|
+
h->kind == RNG_ONE_OR_MORE);
|
|
637
|
+
if (st->unit[b]) {
|
|
638
|
+
if (repeatable && r > i) return; /* hold the cursor */
|
|
639
|
+
st->done[b] = 1;
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
if (repeatable && r > i) return; /* hold the cursor */
|
|
643
|
+
st->cur[b] = h->next;
|
|
644
|
+
st->done[b] = (h->next == NULL);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
static size_t rng_interleave_try(RngVal* v, IlvState* st,
|
|
648
|
+
LeptrisNodeRef* kids, size_t n,
|
|
649
|
+
size_t i, unsigned held_mask) {
|
|
650
|
+
size_t b;
|
|
651
|
+
for (b = 0; b < st->cn; b++) {
|
|
652
|
+
if (!st->done[b]) break;
|
|
653
|
+
}
|
|
654
|
+
if (b == st->cn) return i; /* every branch exhausted */
|
|
655
|
+
if (++st->steps > 200000) return (size_t)-1;
|
|
656
|
+
/* The search returns the FURTHEST completion, not the first: a
|
|
657
|
+
* branch finishing early can complete at a position that strands
|
|
658
|
+
* a repeatable member's later match (ruby#650 case 4: out=4 vs
|
|
659
|
+
* the required n=5). */
|
|
660
|
+
size_t best = (size_t)-1;
|
|
661
|
+
for (b = 0; b < st->cn; b++) {
|
|
662
|
+
if (st->done[b]) continue;
|
|
663
|
+
RngPattern* h = st->cur[b];
|
|
664
|
+
int repeatable = (h->kind == RNG_ZERO_OR_MORE ||
|
|
665
|
+
h->kind == RNG_ONE_OR_MORE);
|
|
666
|
+
size_t r = match_seq(v, h, kids, n, i);
|
|
667
|
+
if (r != (size_t)-1 && r > i) {
|
|
668
|
+
/* consuming: advance-or-hold, recurse at the new frontier
|
|
669
|
+
* — the frontier moved, so every hold is forgettable */
|
|
670
|
+
RngPattern* save = st->cur[b];
|
|
671
|
+
int save_done = st->done[b];
|
|
672
|
+
ilv_advance(st, b, h, r, i);
|
|
673
|
+
size_t out = rng_interleave_try(v, st, kids, n, r, 0);
|
|
674
|
+
st->cur[b] = save; /* backtrack */
|
|
675
|
+
st->done[b] = save_done;
|
|
676
|
+
if (out != (size_t)-1 && (best == (size_t)-1 || out > best))
|
|
677
|
+
best = out;
|
|
678
|
+
if (best == n) break; /* complete — cannot beat */
|
|
679
|
+
v->failed = 0;
|
|
680
|
+
v->err[0] = 0;
|
|
681
|
+
}
|
|
682
|
+
if (r != (size_t)-1 && r == i) {
|
|
683
|
+
if (repeatable && !(held_mask & (1u << b))) {
|
|
684
|
+
/* zero-width: the member may still feed at a LATER
|
|
685
|
+
* position — hold it and let the others move first
|
|
686
|
+
* (the mask guards the same-branch same-frontier
|
|
687
|
+
* ping-pong: each branch holds at most once per
|
|
688
|
+
* frontier) */
|
|
689
|
+
size_t out = rng_interleave_try(v, st, kids, n, i,
|
|
690
|
+
held_mask | (1u << b));
|
|
691
|
+
if (out != (size_t)-1 && (best == (size_t)-1 ||
|
|
692
|
+
out > best))
|
|
693
|
+
best = out;
|
|
694
|
+
if (best == n) break;
|
|
695
|
+
}
|
|
696
|
+
/* or the branch finishes here */
|
|
697
|
+
RngPattern* save = st->cur[b];
|
|
698
|
+
int save_done = st->done[b];
|
|
699
|
+
st->done[b] = 1;
|
|
700
|
+
size_t out = rng_interleave_try(v, st, kids, n, r, -1);
|
|
701
|
+
st->cur[b] = save; /* backtrack */
|
|
702
|
+
st->done[b] = save_done;
|
|
703
|
+
if (out != (size_t)-1 && (best == (size_t)-1 || out > best))
|
|
704
|
+
best = out;
|
|
705
|
+
if (best == n) break;
|
|
706
|
+
v->failed = 0;
|
|
707
|
+
v->err[0] = 0;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (r == (size_t)-1) {
|
|
711
|
+
v->failed = 0; /* speculative: try the next branch */
|
|
712
|
+
v->err[0] = 0;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return best;
|
|
716
|
+
}
|
|
717
|
+
|
|
605
718
|
static int leaf_matches(RngVal* v, RngPattern* p, LeptrisNodeRef node) {
|
|
606
719
|
LeptrisElement e = (LeptrisElement)node;
|
|
607
720
|
switch (p->kind) {
|
|
@@ -663,55 +776,34 @@ static size_t match_seq(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
|
663
776
|
return i;
|
|
664
777
|
}
|
|
665
778
|
case RNG_INTERLEAVE: {
|
|
666
|
-
/* Any order; every branch must be satisfied.
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
for (RngPattern* c = p->first_child; c && cn < 64;
|
|
677
|
-
c = c->next)
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
for (size_t b = 0; b < cn; b++) {
|
|
685
|
-
if (used[b]) continue;
|
|
686
|
-
size_t r = match_seq(v, ch[b], kids, n, i);
|
|
687
|
-
if (r != (size_t)-1 && r > i) {
|
|
688
|
-
used[b] = 1;
|
|
689
|
-
i = r;
|
|
690
|
-
progressed = 1;
|
|
691
|
-
} else if (r != (size_t)-1) {
|
|
692
|
-
/* zero-width here: leave the branch unused so
|
|
693
|
-
* a later position can still feed it. */
|
|
694
|
-
v->failed = 0;
|
|
695
|
-
v->err[0] = 0;
|
|
696
|
-
} else {
|
|
697
|
-
v->failed = 0;
|
|
698
|
-
v->err[0] = 0;
|
|
699
|
-
}
|
|
779
|
+
/* Any order; every branch must be satisfied. The cursor
|
|
780
|
+
* machine above: branches match non-contiguously with
|
|
781
|
+
* full backtracking. The earlier fixpoint walk could not
|
|
782
|
+
* DEFER a branch — combine="interleave" merges wrap each
|
|
783
|
+
* body in a GROUP (#2089), and group(base) as one branch
|
|
784
|
+
* must be able to PAUSE mid-sequence while another branch
|
|
785
|
+
* consumes at the frontier (ruby#650: the added element
|
|
786
|
+
* may sit between any two base elements, §4.17). */
|
|
787
|
+
IlvState st;
|
|
788
|
+
memset(&st, 0, sizeof(st));
|
|
789
|
+
for (RngPattern* c = p->first_child; c && st.cn < 64;
|
|
790
|
+
c = c->next) {
|
|
791
|
+
if (c->kind == RNG_GROUP && c->first_child) {
|
|
792
|
+
st.cur[st.cn] = c->first_child;
|
|
793
|
+
st.unit[st.cn] = 0;
|
|
794
|
+
} else {
|
|
795
|
+
st.cur[st.cn] = c;
|
|
796
|
+
st.unit[st.cn] = 1;
|
|
700
797
|
}
|
|
798
|
+
st.done[st.cn] = 0;
|
|
799
|
+
st.cn++;
|
|
701
800
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
size_t r = match_seq(v, ch[b], kids, n, i);
|
|
705
|
-
if (r == (size_t)-1 || r != i) {
|
|
706
|
-
/* A branch that consumes here contradicts the
|
|
707
|
-
* fixpoint above — treat as unsatisfied. */
|
|
708
|
-
return (size_t)-1;
|
|
709
|
-
}
|
|
801
|
+
size_t out = rng_interleave_try(v, &st, kids, n, idx, 0);
|
|
802
|
+
if (out == (size_t)-1) {
|
|
710
803
|
v->failed = 0;
|
|
711
804
|
v->err[0] = 0;
|
|
712
|
-
used[b] = 1;
|
|
713
805
|
}
|
|
714
|
-
return
|
|
806
|
+
return out;
|
|
715
807
|
}
|
|
716
808
|
case RNG_OPTIONAL: {
|
|
717
809
|
/* ruby-adjacent leptris#2078: the XML form flattens a
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Grammar-aware HTML seed generator (SOTA C1 #2051): documents that
|
|
3
|
+
anchor the tokenizer's STATE SPACE — foreign content (SVG/MATH with
|
|
4
|
+
integration points), CDATA-ish surprises, self-closing tags, weird
|
|
5
|
+
names, implied end tags, attributes with odd spellings, comments/
|
|
6
|
+
doctypes in odd positions. HTML parsing is error-recovery by design;
|
|
7
|
+
the generator exercises the recovery paths from INSIDE the grammar
|
|
8
|
+
rather than at byte-flip distance. Deterministic under --seed.
|
|
9
|
+
|
|
10
|
+
Usage: gen_html_seeds.py OUTDIR [--seed N] [--count N]
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import os
|
|
15
|
+
import random
|
|
16
|
+
|
|
17
|
+
BLOCK = ["div", "p", "section", "li", "td", "tr", "table"]
|
|
18
|
+
FOREIGN = ["svg", "math"]
|
|
19
|
+
SVG_KIDS = ["path", "circle", "g", "foreignObject", "desc", "title",
|
|
20
|
+
"text", "clipPath", "use"]
|
|
21
|
+
MATH_KIDS = ["mi", "mo", "mn", "mrow", "msup", "annotation-xml"]
|
|
22
|
+
WEIRD_TAGS = ["a<b", "foo.bar", "x:y", "font-face-uri", "set"]
|
|
23
|
+
TEXTS = ["hello", "42", "a < b", "<notatag", "&amp", " "]
|
|
24
|
+
ATTR_SPELLINGS = ['class="x"', "id=noquotes", "data-x='y'",
|
|
25
|
+
"DATA-UPPER=1", 'disabled', '=""',
|
|
26
|
+
'style="color:red"']
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def attrs(rng):
|
|
30
|
+
return (" " + " ".join(rng.sample(
|
|
31
|
+
ATTR_SPELLINGS, rng.randint(0, 3)))) if rng.random() < 0.8 else ""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def html(rng, depth):
|
|
35
|
+
out = []
|
|
36
|
+
for _ in range(rng.randint(1, 4)):
|
|
37
|
+
r = rng.random()
|
|
38
|
+
if r < 0.30 and depth > 0:
|
|
39
|
+
t = rng.choice(BLOCK)
|
|
40
|
+
out.append(f"<{t}{attrs(rng)}>{html(rng, depth - 1)}</{t}>")
|
|
41
|
+
elif r < 0.50:
|
|
42
|
+
f = rng.choice(FOREIGN)
|
|
43
|
+
kids = rng.choice(SVG_KIDS) if f == "svg" else rng.choice(MATH_KIDS)
|
|
44
|
+
inner = "".join(
|
|
45
|
+
f"<{kids}{attrs(rng)}{rng.choice(['', ' />', ' /'])}>"
|
|
46
|
+
for _ in range(rng.randint(1, 3)))
|
|
47
|
+
tail = rng.choice(["", "<![CDATA[x]]>", "</p>"])
|
|
48
|
+
out.append(f"<{f}{attrs(rng)}>{inner}{tail}</{f}>")
|
|
49
|
+
elif r < 0.58:
|
|
50
|
+
out.append(rng.choice(TEXTS))
|
|
51
|
+
elif r < 0.64:
|
|
52
|
+
out.append(f"<!-- comment {rng.randint(0, 9)} -->")
|
|
53
|
+
elif r < 0.70:
|
|
54
|
+
out.append(f"<{rng.choice(WEIRD_TAGS)}{attrs(rng)}>")
|
|
55
|
+
elif r < 0.76:
|
|
56
|
+
out.append(rng.choice(["<br>", "<hr/>", "<img src=x>",
|
|
57
|
+
"<input value=?>"]))
|
|
58
|
+
elif r < 0.82:
|
|
59
|
+
out.append(rng.choice(["<p>", "</p>", "<li>", "</li>"]))
|
|
60
|
+
elif r < 0.88:
|
|
61
|
+
out.append(f"<script{attrs(rng)}>if (a<b) x();</script>")
|
|
62
|
+
elif r < 0.94:
|
|
63
|
+
out.append(f"<style>p {{ color: red }}</style>")
|
|
64
|
+
else:
|
|
65
|
+
out.append("<template><td><a href=#>t</td></template>")
|
|
66
|
+
return "".join(out)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def gen_doc(rng):
|
|
70
|
+
parts = []
|
|
71
|
+
if rng.random() < 0.7:
|
|
72
|
+
parts.append(rng.choice([
|
|
73
|
+
"<!DOCTYPE html>", "<!doctype html>",
|
|
74
|
+
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">",
|
|
75
|
+
]))
|
|
76
|
+
parts.append("<html>")
|
|
77
|
+
if rng.random() < 0.6:
|
|
78
|
+
parts.append(f"<head><meta charset=utf-8><title>t</title></head>")
|
|
79
|
+
parts.append(f"<body>{html(rng, rng.randint(1, 5))}</body>")
|
|
80
|
+
parts.append("</html>")
|
|
81
|
+
return "".join(parts) + "\n"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def main():
|
|
85
|
+
ap = argparse.ArgumentParser()
|
|
86
|
+
ap.add_argument("outdir")
|
|
87
|
+
ap.add_argument("--seed", type=int, default=0)
|
|
88
|
+
ap.add_argument("--count", type=int, default=100)
|
|
89
|
+
args = ap.parse_args()
|
|
90
|
+
|
|
91
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
92
|
+
rng = random.Random(args.seed)
|
|
93
|
+
for i in range(args.count):
|
|
94
|
+
with open(os.path.join(args.outdir, f"gen{i:04d}.html"), "w",
|
|
95
|
+
encoding="utf-8") as f:
|
|
96
|
+
f.write(gen_doc(rng))
|
|
97
|
+
print(f"wrote {args.count} seeds to {args.outdir}")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
main()
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Grammar-aware XPath/XQuery seed generator (SOTA C1 #2051). The
|
|
3
|
+
xpath_corpus's hand-written seeds are five lines; mutation explores
|
|
4
|
+
expression STRUCTURE from them slowly. This generator composes
|
|
5
|
+
expressions across the grammar: axis steps with predicates, function
|
|
6
|
+
calls (0/1/2-arg), unions, comparisons, arithmetic, numeric and
|
|
7
|
+
string literals, variables, path/absolute mixes, filtered primaries,
|
|
8
|
+
XQuery FLWOR spellings. Well-formed by construction; deterministic
|
|
9
|
+
under --seed. The nightly feeds them to the fuzz_xpath leg.
|
|
10
|
+
|
|
11
|
+
Usage: gen_xpath_seeds.py OUTDIR [--seed N] [--count N]
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import os
|
|
16
|
+
import random
|
|
17
|
+
|
|
18
|
+
NAMES = ["a", "b", "item", "r", "node", "leaf", "span", "*"]
|
|
19
|
+
ATTRS = ["id", "kind", "status", "sku"]
|
|
20
|
+
AXES = ["child::", "descendant::", "following-sibling::",
|
|
21
|
+
"preceding-sibling::", "ancestor::", "self::", "attribute::"]
|
|
22
|
+
FUNCS0 = ["position()", "last()", "count(//*)", "true()", "false()",
|
|
23
|
+
"string-length(name())"]
|
|
24
|
+
FUNCS1 = ["string-length(.)", "number(@id)", "contains(@kind,'x')",
|
|
25
|
+
"starts-with(name(),'a')", "normalize-space(.)",
|
|
26
|
+
"string(.)", "not(.)", "round(number(@id))",
|
|
27
|
+
"floor(number(@id))", "ceiling(number(@id))"]
|
|
28
|
+
FUNCS2 = ["substring(.,1,2)", "concat('x',.)", "substring-after(name(),'a')",
|
|
29
|
+
"contains(.,'z')"]
|
|
30
|
+
LITS = ["1", "0", "2.5", "-3", "'x'", "\"y\"", "'a b'", "1e2", ".5"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def predicate(rng, depth):
|
|
34
|
+
r = rng.random()
|
|
35
|
+
if r < 0.25:
|
|
36
|
+
return str(rng.randint(1, 3))
|
|
37
|
+
if r < 0.5:
|
|
38
|
+
return rng.choice(FUNCS0 + FUNCS1)
|
|
39
|
+
if r < 0.7:
|
|
40
|
+
rhs = rng.choice(["1", "'x'", "true()"])
|
|
41
|
+
op = rng.choice(["=", "!="])
|
|
42
|
+
return f"@{rng.choice(ATTRS)}{op}{rhs}"
|
|
43
|
+
return comparison(rng, depth - 1)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def step(rng, depth):
|
|
47
|
+
axis = rng.choice(AXES) if rng.random() < 0.4 else ""
|
|
48
|
+
name = rng.choice(NAMES)
|
|
49
|
+
s = f"{axis}{name}"
|
|
50
|
+
if depth > 0:
|
|
51
|
+
while rng.random() < 0.5:
|
|
52
|
+
s = f"{s}[{predicate(rng, depth - 1)}]"
|
|
53
|
+
return s
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def path(rng, depth):
|
|
57
|
+
p = step(rng, depth)
|
|
58
|
+
n = rng.randint(0, 2)
|
|
59
|
+
for _ in range(n):
|
|
60
|
+
sep = "//" if rng.random() < 0.2 else "/"
|
|
61
|
+
p = f"{p}{sep}{step(rng, depth - 1)}"
|
|
62
|
+
return p
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def comparison(rng, depth):
|
|
66
|
+
if depth <= 0:
|
|
67
|
+
return rng.choice(LITS)
|
|
68
|
+
lhs = operand(rng, depth - 1)
|
|
69
|
+
op = rng.choice(["=", "!=", "<", ">", "<=", ">=", "!=", "="])
|
|
70
|
+
rhs = operand(rng, depth - 1)
|
|
71
|
+
return f"{lhs} {op} {rhs}"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def operand(rng, depth):
|
|
75
|
+
r = rng.random()
|
|
76
|
+
if r < 0.35:
|
|
77
|
+
return path(rng, depth)
|
|
78
|
+
if r < 0.55:
|
|
79
|
+
return rng.choice(FUNCS0 + FUNCS1 + FUNCS2)
|
|
80
|
+
if r < 0.7:
|
|
81
|
+
return rng.choice(LITS)
|
|
82
|
+
if r < 0.85:
|
|
83
|
+
return f"({comparison(rng, depth - 1)})"
|
|
84
|
+
return f"{operand(rng, depth - 1)} {rng.choice(['+', '-', 'div', 'mod'])} {rng.choice(LITS)}"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def expr(rng, depth):
|
|
88
|
+
e = comparison(rng, depth)
|
|
89
|
+
while rng.random() < 0.35:
|
|
90
|
+
e = f"{e} | {path(rng, depth - 1)}"
|
|
91
|
+
if rng.random() < 0.12:
|
|
92
|
+
var = rng.choice(["$x", "$item", "$n"])
|
|
93
|
+
inner = expr(rng, depth - 1).replace("'", "\\'")
|
|
94
|
+
e = f"(for {var} in (1,2) return if ({e}) then {var} else ())"
|
|
95
|
+
return e
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def main():
|
|
99
|
+
ap = argparse.ArgumentParser()
|
|
100
|
+
ap.add_argument("outdir")
|
|
101
|
+
ap.add_argument("--seed", type=int, default=0)
|
|
102
|
+
ap.add_argument("--count", type=int, default=200)
|
|
103
|
+
args = ap.parse_args()
|
|
104
|
+
|
|
105
|
+
rng = random.Random(args.seed)
|
|
106
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
107
|
+
seen = set()
|
|
108
|
+
n = 0
|
|
109
|
+
for _ in range(args.count):
|
|
110
|
+
e = expr(rng, rng.randint(1, 4))
|
|
111
|
+
if e in seen or len(e) > 400:
|
|
112
|
+
continue
|
|
113
|
+
seen.add(e)
|
|
114
|
+
# One file per expression: the fuzz legs take corpus
|
|
115
|
+
# DIRECTORIES, and libFuzzer mutates per file.
|
|
116
|
+
with open(os.path.join(args.outdir, f"gen{n:04d}.xpath"), "w") as f:
|
|
117
|
+
f.write(e + "\n")
|
|
118
|
+
n += 1
|
|
119
|
+
print(f"wrote {n} expressions to {args.outdir}")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
main()
|
|
@@ -1967,3 +1967,50 @@ TEST(Rng2088CombineMerge, RepeatedChoiceMergeKeepsEarlierBodiesGrouped) {
|
|
|
1967
1967
|
}
|
|
1968
1968
|
leptris_rng_free(rng);
|
|
1969
1969
|
}
|
|
1970
|
+
|
|
1971
|
+
/* ruby#650 (regression in 1.9.428.0): combine="interleave" makes the
|
|
1972
|
+
* merged pattern interleave(base, added) — RELAX NG §4.17. An element
|
|
1973
|
+
* of the ADDED pattern may sit BETWEEN any two elements of the base
|
|
1974
|
+
* sequence: the merged document is any interleaving of the two body
|
|
1975
|
+
* sequences. The bare-chain pre-428 form accidentally allowed this
|
|
1976
|
+
* (every element was its own branch); the grouped form needs the
|
|
1977
|
+
* interleave walk to DEFER a branch — a full partition search with
|
|
1978
|
+
* backtracking, like Jing. */
|
|
1979
|
+
TEST(Rng650InterleaveCombine, AddedElementMaySplitTheBaseSequence) {
|
|
1980
|
+
const char* schema =
|
|
1981
|
+
"<grammar xmlns=\"http://relaxng.org/ns/structure/1.0\">"
|
|
1982
|
+
"<start><element name=\"ext\"><ref name=\"Ext\"/></element></start>"
|
|
1983
|
+
"<define name=\"Ext\">"
|
|
1984
|
+
"<element name=\"doctype\"><text/></element>"
|
|
1985
|
+
"<element name=\"flavor\"><text/></element>"
|
|
1986
|
+
"<zeroOrMore><element name=\"ics\"><text/></element></zeroOrMore>"
|
|
1987
|
+
"</define>"
|
|
1988
|
+
"<define name=\"Ext\" combine=\"interleave\">"
|
|
1989
|
+
"<optional><element name=\"price-code\"><text/></element></optional>"
|
|
1990
|
+
"</define>"
|
|
1991
|
+
"</grammar>";
|
|
1992
|
+
LeptrisRelaxNG rng =
|
|
1993
|
+
leptris_rng_parse(schema, strlen(schema), nullptr);
|
|
1994
|
+
ASSERT_NE(rng, nullptr);
|
|
1995
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
1996
|
+
struct { const char* doc; int want; const char* why; } cases[] = {
|
|
1997
|
+
{"<ext><doctype/><price-code/><flavor/></ext>", 1,
|
|
1998
|
+
"the added element BETWEEN two base elements (§4.17)"},
|
|
1999
|
+
{"<ext><doctype/><flavor/><price-code/></ext>", 1,
|
|
2000
|
+
"the added element after the base"},
|
|
2001
|
+
{"<ext><price-code/><doctype/><flavor/></ext>", 1,
|
|
2002
|
+
"the added element before the base"},
|
|
2003
|
+
{"<ext><doctype/><flavor/><ics/><price-code/><ics/></ext>", 1,
|
|
2004
|
+
"ics both sides of the added element (the relaton ics shape)"},
|
|
2005
|
+
{"<ext><doctype/></ext>", 0, "flavor is required"},
|
|
2006
|
+
{"<ext><price-code/></ext>", 0, "the base is still required"},
|
|
2007
|
+
};
|
|
2008
|
+
for (auto& c : cases) {
|
|
2009
|
+
LeptrisDocument d = leptris_parse_string(c.doc, strlen(c.doc), &st);
|
|
2010
|
+
ASSERT_NE(d, nullptr) << c.doc;
|
|
2011
|
+
EXPECT_EQ(leptris_rng_validate(rng, d), c.want)
|
|
2012
|
+
<< c.why << " — doc: " << c.doc;
|
|
2013
|
+
leptris_document_free(d);
|
|
2014
|
+
}
|
|
2015
|
+
leptris_rng_free(rng);
|
|
2016
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
|
3
3
|
"name": "leptris",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.429",
|
|
5
5
|
"description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
|
|
6
6
|
"homepage": "https://github.com/leptris/leptris",
|
|
7
7
|
"license": "MIT",
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: leptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.429.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -913,6 +913,7 @@ files:
|
|
|
913
913
|
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0038.xsl
|
|
914
914
|
- vendor-src/libleptris/test/fuzz/corpus/gen/gen_0039.xsl
|
|
915
915
|
- vendor-src/libleptris/test/fuzz/corpus/html_foreign_cdata_short_opener.bin
|
|
916
|
+
- vendor-src/libleptris/test/fuzz/corpus/html_tree_amplification_timeout.bin
|
|
916
917
|
- vendor-src/libleptris/test/fuzz/corpus/seed1
|
|
917
918
|
- vendor-src/libleptris/test/fuzz/corpus/seed2
|
|
918
919
|
- vendor-src/libleptris/test/fuzz/corpus/xpath_bracket_nesting_stack_overflow.bin
|
|
@@ -932,7 +933,9 @@ files:
|
|
|
932
933
|
- vendor-src/libleptris/test/fuzz/fuzz_parse.c
|
|
933
934
|
- vendor-src/libleptris/test/fuzz/fuzz_xpath.c
|
|
934
935
|
- vendor-src/libleptris/test/fuzz/fuzz_xslt.c
|
|
936
|
+
- vendor-src/libleptris/test/fuzz/generators/gen_html_seeds.py
|
|
935
937
|
- vendor-src/libleptris/test/fuzz/generators/gen_xml_seeds.py
|
|
938
|
+
- vendor-src/libleptris/test/fuzz/generators/gen_xpath_seeds.py
|
|
936
939
|
- vendor-src/libleptris/test/fuzz/generators/gen_xslt_seeds.py
|
|
937
940
|
- vendor-src/libleptris/test/html/html5lib-redlist.txt
|
|
938
941
|
- vendor-src/libleptris/test/html/html5lib-tests/LICENSE
|