Skip to content

Commit

Permalink
strip all null bytes from utf8 strings that come from substreams, lik…
Browse files Browse the repository at this point in the history
…e it's done on other sources (#4328)
  • Loading branch information
sduchesneau authored Jan 30, 2023
1 parent af4f653 commit 7118fd8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chain/substreams/src/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,15 @@ fn decode_value(value: &crate::codec::value::Typed) -> Result<Value, MappingErro
.map(Value::BigInt)
.map_err(|err| MappingError::Unknown(anyhow::Error::from(err))),

Typed::String(new_value) => Ok(Value::String(new_value.clone())),
Typed::String(new_value) => {
let mut string = new_value.clone();

// Strip null characters since they are not accepted by Postgres.
if string.contains('\u{0000}') {
string = string.replace('\u{0000}', "");
}
Ok(Value::String(string))
}

Typed::Bytes(new_value) => base64::decode(&new_value)
.map(|bs| Value::Bytes(Bytes::from(bs.as_ref())))
Expand Down

0 comments on commit 7118fd8

Please sign in to comment.