mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
ox: only process proper messages
We only want to have the decrypted message or the alternative body in
message->plain.
Also let's print error messages if it makes sense and log other issues.
Partly addresses the commit in the comit mesage of:
2dc0cc489c
This commit is contained in:
parent
1eaa2c1529
commit
66eeccf408
@ -1467,14 +1467,13 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
|
||||
#ifdef HAVE_LIBGPGME
|
||||
xmpp_stanza_t* ox = xmpp_stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
|
||||
if (ox) {
|
||||
message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
|
||||
if (message->plain) {
|
||||
xmpp_stanza_t* x = xmpp_stanza_new_from_string(connection_get_ctx(), message->plain);
|
||||
if (x) {
|
||||
xmpp_stanza_t* p = xmpp_stanza_get_child_by_name(x, "payload");
|
||||
gchar* decrypted = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
|
||||
if (decrypted) {
|
||||
xmpp_stanza_t* decrypted_stanza = xmpp_stanza_new_from_string(connection_get_ctx(), decrypted);
|
||||
if (decrypted_stanza) {
|
||||
xmpp_stanza_t* p = xmpp_stanza_get_child_by_name(decrypted_stanza, "payload");
|
||||
if (!p) {
|
||||
log_warning("OX Stanza - no Payload");
|
||||
message->plain = "OX error: No payload found";
|
||||
return;
|
||||
}
|
||||
xmpp_stanza_t* b = xmpp_stanza_get_child_by_name(p, "body");
|
||||
@ -1484,18 +1483,18 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
|
||||
}
|
||||
message->plain = xmpp_stanza_get_text(b);
|
||||
message->encrypted = xmpp_stanza_get_text(ox);
|
||||
if (message->plain == NULL) {
|
||||
message->plain = xmpp_stanza_get_text(stanza);
|
||||
}
|
||||
} else {
|
||||
message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)";
|
||||
cons_show("Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)");
|
||||
log_warning("OX Stanza text to stanza failed");
|
||||
}
|
||||
} else {
|
||||
message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)";
|
||||
// get alternative text from message body
|
||||
xmpp_stanza_t* b = xmpp_stanza_get_child_by_name(stanza, "body");
|
||||
if (b) {
|
||||
message->plain = xmpp_stanza_get_text(b);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
message->plain = "OX stanza without openpgp name";
|
||||
log_warning("OX Stanza without openpgp stanza");
|
||||
}
|
||||
#endif // HAVE_LIBGPGME
|
||||
|
Loading…
Reference in New Issue
Block a user