snarkVM
snarkVM copied to clipboard
[Bug] Replace encoding crate with encoding_rs
🐛 Bug Report
Because cargo audit is triggered by it.
It is currently an exception: https://github.com/ProvableHQ/snarkVM/pull/2748/files#diff-42d80c82c252835c55a95ccaecb4b8583244e79721e5dd62864e11e2dc89eb65R7
Hey @vicsn I am new to SnarkVM and gave this a try.
To replace the encoding crate as used here .
We could use the ISO_8859_5.encode(&rust_text) function of the encoding_rs crate directly but it does not encode without replacement as we want (as we used the EncodeTrap::Strict in the present code).
So we would have to make an encoder and then use the _without_replacement variant functions as mentioned in the docs , but this function needs an output buffer.
let mut output = vec![u8, output_size];
let mut encoder = ISO_8859_5.encoder();
let (result, _ ) = encoder.encode_from_utf8_to_vec_without_replacement(&rust_text, output, true);
match result {
EncoderResult::InputEmpty => {
Ok(output)
}
EncoderResult::Unmappable(_) => {
Err($crate::errors::ParameterError::Wasm("Parameter decoding failed".to_string()))
}
// rest of the match statement
}