mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -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
|
#ifdef HAVE_LIBGPGME
|
||||||
xmpp_stanza_t* ox = xmpp_stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
|
xmpp_stanza_t* ox = xmpp_stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
|
||||||
if (ox) {
|
if (ox) {
|
||||||
message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
|
gchar* decrypted = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
|
||||||
if (message->plain) {
|
if (decrypted) {
|
||||||
xmpp_stanza_t* x = xmpp_stanza_new_from_string(connection_get_ctx(), message->plain);
|
xmpp_stanza_t* decrypted_stanza = xmpp_stanza_new_from_string(connection_get_ctx(), decrypted);
|
||||||
if (x) {
|
if (decrypted_stanza) {
|
||||||
xmpp_stanza_t* p = xmpp_stanza_get_child_by_name(x, "payload");
|
xmpp_stanza_t* p = xmpp_stanza_get_child_by_name(decrypted_stanza, "payload");
|
||||||
if (!p) {
|
if (!p) {
|
||||||
log_warning("OX Stanza - no Payload");
|
log_warning("OX Stanza - no Payload");
|
||||||
message->plain = "OX error: No payload found";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmpp_stanza_t* b = xmpp_stanza_get_child_by_name(p, "body");
|
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->plain = xmpp_stanza_get_text(b);
|
||||||
message->encrypted = xmpp_stanza_get_text(ox);
|
message->encrypted = xmpp_stanza_get_text(ox);
|
||||||
if (message->plain == NULL) {
|
|
||||||
message->plain = xmpp_stanza_get_text(stanza);
|
|
||||||
}
|
|
||||||
} else {
|
} 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");
|
log_warning("OX Stanza text to stanza failed");
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
message->plain = "OX stanza without openpgp name";
|
|
||||||
log_warning("OX Stanza without openpgp stanza");
|
log_warning("OX Stanza without openpgp stanza");
|
||||||
}
|
}
|
||||||
#endif // HAVE_LIBGPGME
|
#endif // HAVE_LIBGPGME
|
||||||
|
Loading…
Reference in New Issue
Block a user