diff --git a/Cargo.toml b/Cargo.toml index d2b07819..b3ac3834 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = ["JSON", "parsing", "deserialization", "iter"] categories = ["parser-implementations", "parsing"] homepage = "https://github.com/pydantic/jiter/" repository = "https://github.com/pydantic/jiter/" -rust-version = "1.73.0" +rust-version = "1.74.0" [profile.bench] debug = true diff --git a/crates/fuzz/fuzz_targets/compare_to_serde.rs b/crates/fuzz/fuzz_targets/compare_to_serde.rs index 114d3bdf..53aad191 100644 --- a/crates/fuzz/fuzz_targets/compare_to_serde.rs +++ b/crates/fuzz/fuzz_targets/compare_to_serde.rs @@ -88,8 +88,13 @@ fn errors_equal(jiter_error: &JiterError, serde_error: &SerdeError, json_data: & } else if matches!(jiter_error.error_type, JiterJsonErrorType::InvalidUnicodeCodePoint) { // https://github.com/serde-rs/json/issues/1083 remove_suffix(&jiter_error_str) == remove_suffix(&serde_error_str) + } else if jiter_error_str.starts_with("invalid escape at line") + && serde_error_str.starts_with("invalid escape at line") + { + // see fuzz failures on #130 + true } else { - return jiter_error_str == serde_error_str; + jiter_error_str == serde_error_str } } diff --git a/crates/jiter/Cargo.toml b/crates/jiter/Cargo.toml index 3914aec1..782f8b0b 100644 --- a/crates/jiter/Cargo.toml +++ b/crates/jiter/Cargo.toml @@ -29,7 +29,7 @@ paste = "1.0.7" serde_json = {version = "1.0.87", features = ["preserve_order", "arbitrary_precision", "float_roundtrip"]} serde = "1.0.147" pyo3 = { workspace = true, features = ["auto-initialize"] } -codspeed-bencher-compat = "2.3.1" +codspeed-bencher-compat = "2.7.1" [build-dependencies] pyo3-build-config = { workspace = true, optional = true } diff --git a/crates/jiter/tests/main.rs b/crates/jiter/tests/main.rs index 8fef5c7a..3d672cd6 100644 --- a/crates/jiter/tests/main.rs +++ b/crates/jiter/tests/main.rs @@ -615,6 +615,16 @@ fn bad_high_order_string_tail() { assert_eq!(e.description(&bytes), "invalid unicode code point at line 1 column 5") } +#[test] +fn invalid_escape_position() { + // from fuzzing on #130 + let bytes = br#""con(\u0trol character (\u000.00"#; + let e = JsonValue::parse(bytes, false).unwrap_err(); + assert_eq!(e.error_type, JsonErrorType::InvalidEscape); + assert_eq!(e.index, 8); + assert_eq!(e.description(bytes), "invalid escape at line 1 column 9") +} + #[test] fn simd_string_sizes() { for i in 0..100 {