From cad485b13cf05fcc9b24baedc4eef5053266b34f Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 18 Oct 2026 16:35:54 +0200 Subject: [PATCH] test(tests): fix the pinned value count past the depth cap (65 + 1000 + 65); doc comment --- crates/core/src/pdf/json_js.rs | 2 +- crates/core/tests/pdf_json_js.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/core/src/pdf/json_js.rs b/crates/core/src/pdf/json_js.rs index df25ec29..319482a9 100644 --- a/crates/core/src/pdf/json_js.rs +++ b/crates/core/src/pdf/json_js.rs @@ -52,7 +52,7 @@ pub fn starts_json_object(data: &[u8]) -> bool { pub struct JsonPrescan { /// `withinJsonDepth`: the bracket depth never went over [`MAX_JSON_DEPTH`]. pub within_depth: bool, - /// Values counted before the scan ended (at the refusal when `within_depth` is false). + /// Values counted over the whole text, whatever the depth verdict. pub values: u64, } diff --git a/crates/core/tests/pdf_json_js.rs b/crates/core/tests/pdf_json_js.rs index 0d3670e9..d2d58774 100644 --- a/crates/core/tests/pdf_json_js.rs +++ b/crates/core/tests/pdf_json_js.rs @@ -70,7 +70,8 @@ fn prescan_keeps_counting_values_past_the_depth_cap() { let deep = format!("{}{}{}", "[".repeat(65), "1,".repeat(1000), "1]".repeat(65)); let scan = prescan(deep.as_bytes()); assert!(!scan.within_depth); - assert_eq!(scan.values, 65 + 1001); + // 65 opens, 1,000 numbers, then one number after each `]`. + assert_eq!(scan.values, 65 + 1000 + 65); } #[test]