Encode causality tokens using URL-safe b64
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

this should fix the pollitem test where the ct was passed in the url
This commit is contained in:
Alex 2022-04-28 11:35:49 +02:00
parent 7362618b97
commit fdbed3f1e8
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -42,11 +42,12 @@ impl CausalContext {
bytes.extend(u64::to_be_bytes(i));
}
base64::encode(bytes)
base64::encode_config(bytes, base64::URL_SAFE_NO_PAD)
}
/// Parse from base64-encoded binary representation
pub fn parse(s: &str) -> Result<Self, Error> {
let bytes = base64::decode(s).ok_or_message("Invalid causality token (bad base64)")?;
let bytes = base64::decode_config(s, base64::URL_SAFE_NO_PAD)
.ok_or_message("Invalid causality token (bad base64)")?;
if bytes.len() % 16 != 8 || bytes.len() < 8 {
return Err(Error::Message(
"Invalid causality token (bad length)".into(),