Last 12 weeks · 0 commits
2 of 6 standards met
Adds two new methods on , mirroring the existing knob: — wraps . Caps the number of internal iterations. — wraps . Caps nested backtracking depth. Motivation Downstream callers running PCRE2 over potentially-adversarial input — for example, a terminal-output highlighter applying user-configured regexes to remote-device output — want explicit upper bounds on worst-case match CPU and recursion. The existing only bounds JIT memory; these two complete the picture on the interpreter path. Implementation Extends in with two new optional fields. Applies them in immediately after . Both PCRE2 setters always return zero per upstream docs, but the return code is 'd defensively so an unexpected upstream change would surface immediately. No new FFI bindings needed — already exports and . Default value is for both, preserving current behavior bit-for-bit. Tests Three new tests in : — against with produces a match-limit error. — against with produces a depth-limit error; same pattern matches with the default. — sanity that the new knobs don't change default behavior. Existing 24 lib tests and 7 doctests still pass; is clean. Smoke-tested by patching a downstream consumer ( ↔ ) to confirm the public API integrates without further changes.
When building the bundled PCRE2 (, or musl targets), enumerates the C sources with and hands them to in that order. yields entries in the filesystem's directory-iteration order, which is stable on any one machine but differs across machines — e.g. ext4 iterates in name-hash order with a per-filesystem seed chosen at mkfs time. That order becomes the member order of the static archive built by , so the same crate version produces byte-different artifacts on different machines. The member order also survives into binaries that link the archive: the linker records one symbol per loaded member, in load order. We found this while verifying the reproducibility of dfinity/ic's GuestOS image: one binary linking pcre2 was the only file in the ~10 GB image that differed between builds on two machines, and the entire difference was the permuted order of its symbol-table entries (the compiled objects themselves were byte-identical). Fix: collect the paths and sort them before adding them to the builder. No functional change — same file set, deterministic order. Repro sketch: build any crate depending on with on two machines with differently-seeded ext4 filesystems (or any two filesystems with different iteration order) and compare of the produced . 🤖 Generated with Claude Code
PCRE2_ALT_EXTENDED_CLASS: In official PCRE2 docs confirm it enables UTS #18 classes like [x&&[^y]], but the safe Rust pcre2 builder does not expose that option today. Using it would require a lower-level pcre2-sys wrapper or upstreaming a builder knob. Sources: PCRE2 syntax docs and API docs. I would like to have a builder knob in pycre2.
Repository: BurntSushi/rust-pcre2. Description: High level Rust bindings to PCRE2. Stars: 64, Forks: 42. Primary language: C. Languages: C (95.9%), Rust (4%), Shell (0.1%). Open PRs: 9, open issues: 6. Last activity: 11mo ago. Community health: 42%. Top contributors: BurntSushi, atouchet, carenas, LeoniePhiline, igor-raits, er-vin, yelkarama, b8591340, bczhc, heiher and others.