weird: need to filter out bidi control characters from sender handles from server
This commit is contained in:
@@ -23,15 +23,32 @@ impl Message {
|
||||
|
||||
impl From<kordophone::model::Message> for Message {
|
||||
fn from(value: kordophone::model::Message) -> Self {
|
||||
let sender_participant = match value.sender {
|
||||
Some(sender) => Participant::Remote {
|
||||
contact_id: None,
|
||||
|
||||
// Weird server quirk: some sender handles are encoded with control characters.
|
||||
handle: sender.chars()
|
||||
.filter(|c| !c.is_control() && !matches!(c,
|
||||
'\u{202A}' | // LRE
|
||||
'\u{202B}' | // RLE
|
||||
'\u{202C}' | // PDF
|
||||
'\u{202D}' | // LRO
|
||||
'\u{202E}' | // RLO
|
||||
'\u{2066}' | // LRI
|
||||
'\u{2067}' | // RLI
|
||||
'\u{2068}' | // FSI
|
||||
'\u{2069}' // PDI
|
||||
))
|
||||
.collect::<String>(),
|
||||
},
|
||||
|
||||
None => Participant::Me,
|
||||
};
|
||||
|
||||
Self {
|
||||
id: value.guid,
|
||||
sender: match value.sender {
|
||||
Some(sender) => Participant::Remote {
|
||||
handle: sender,
|
||||
contact_id: None,
|
||||
},
|
||||
None => Participant::Me,
|
||||
},
|
||||
sender: sender_participant,
|
||||
text: value.text,
|
||||
date: DateTime::from_timestamp(
|
||||
value.date.unix_timestamp(),
|
||||
|
||||
@@ -279,8 +279,6 @@ impl DbusRepository for DBusAgent {
|
||||
// Remove the attachment placeholder here.
|
||||
let text = msg.text.replace("\u{FFFC}", "");
|
||||
|
||||
log::debug!("sender: {:?}", msg.sender.clone());
|
||||
|
||||
map.insert("text".into(), arg::Variant(Box::new(text)));
|
||||
map.insert(
|
||||
"date".into(),
|
||||
@@ -291,8 +289,6 @@ impl DbusRepository for DBusAgent {
|
||||
arg::Variant(Box::new(self.resolve_participant_display_name(&msg.sender.into()))),
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Attachments array
|
||||
let attachments: Vec<arg::PropMap> = msg
|
||||
.attachments
|
||||
|
||||
Reference in New Issue
Block a user