mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
fix: do not allow to edit html messages (#6564)
closes https://github.com/deltachat/deltachat-core-rust/issues/6561
This commit is contained in:
@@ -3141,6 +3141,7 @@ pub async fn send_edit_request(context: &Context, msg_id: MsgId, new_text: Strin
|
||||
"Can edit only own messages"
|
||||
);
|
||||
ensure!(!original_msg.is_info(), "Cannot edit info messages");
|
||||
ensure!(!original_msg.has_html(), "Cannot edit HTML messages");
|
||||
ensure!(
|
||||
original_msg.viewtype != Viewtype::VideochatInvitation,
|
||||
"Cannot edit videochat invitations"
|
||||
|
||||
@@ -3710,3 +3710,21 @@ async fn test_receive_edit_request_after_removal() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_cannot_edit_html() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob = &tcm.bob().await;
|
||||
let chat = alice.create_chat(bob).await;
|
||||
|
||||
let mut msg = Message::new_text("plain text".to_string());
|
||||
msg.set_html(Some("<b>html</b> text".to_string()));
|
||||
send_msg(alice, chat.id, &mut msg).await.unwrap();
|
||||
assert!(msg.has_html());
|
||||
assert!(send_edit_request(alice, msg.id, "foo".to_string())
|
||||
.await
|
||||
.is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user