From 928d8283fea66b267b4f7df5f24d2f835af4ffe9 Mon Sep 17 00:00:00 2001 From: Christopher Gadzinski Date: Mon, 9 May 2022 00:34:42 +0100 Subject: [PATCH 1/2] don't error on messagepack values encoding invalid strings --- src/bridge/events.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bridge/events.rs b/src/bridge/events.rs index 61bf41b..dad59fc 100644 --- a/src/bridge/events.rs +++ b/src/bridge/events.rs @@ -380,7 +380,10 @@ fn parse_map(map_value: Value) -> Result> { } fn parse_string(string_value: Value) -> Result { - string_value.try_into().map_err(ParseError::String) + match string_value { + Value::String(s) => Ok(s.into_str().unwrap_or_else(|| String::from("?"))), + _ => Err(ParseError::String(string_value)) + } } fn parse_u64(u64_value: Value) -> Result { From 416ecd809426165894a0b188d39760c4dc3dbf3c Mon Sep 17 00:00:00 2001 From: Christopher Gadzinski Date: Mon, 9 May 2022 12:53:45 +0100 Subject: [PATCH 2/2] use better placeholder string --- src/bridge/events.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bridge/events.rs b/src/bridge/events.rs index dad59fc..731daee 100644 --- a/src/bridge/events.rs +++ b/src/bridge/events.rs @@ -381,8 +381,8 @@ fn parse_map(map_value: Value) -> Result> { fn parse_string(string_value: Value) -> Result { match string_value { - Value::String(s) => Ok(s.into_str().unwrap_or_else(|| String::from("?"))), - _ => Err(ParseError::String(string_value)) + Value::String(s) => Ok(s.into_str().unwrap_or_else(|| String::from("\u{FFFD}"))), + _ => Err(ParseError::String(string_value)), } }