Skip to content

Commit

Permalink
Add surrogate pair exception to json superset fuzzer
Browse files Browse the repository at this point in the history
Surrogate pairs are not supported by RCL on purpose, so when that can be
parsed by Serde but is rejected by RCL, we shouldn't fail the fuzzer on
it.
  • Loading branch information
ruuda committed Aug 24, 2024
1 parent 7892b7c commit 13ca286
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions fuzz/src/uber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,18 @@ fn fuzz_eval_json_superset(loader: &mut Loader, input: &str) {
Ok(..) => {
// Works as intended.
}
Err(err) if format!("{err:?}").contains("Overflow") => {
// In cases of a large integer or large exponent, Serde parses it
// into a different data type or into a float that goes Inf, but RCL
// cannot represent those, so the incompatibility here is
// intentional.
Err(err) => {
let msg = format!("{err:?}");
if msg.contains("Overflow") {
// In cases of a large integer or large exponent, Serde parses
// it into a different data type or into a float that goes Inf,
// but RCL cannot represent those, so the incompatibility here
// is intentional.
} else if msg.contains("not a Unicode scalar value") {
// RCL does not support surrogate pairs on purpose.
} else {
panic!("If Serde can parse it, RCL should be able to, but got: {msg}");
}
}
Err(err) => panic!("If Serde can parse it, RCL should be able to, but got: {err:?}"),
}
}

0 comments on commit 13ca286

Please sign in to comment.