Bugfixes for OX implementation

* autocomplete for /ox discover
 * fixed help description
 * Implemented /ox char command
 * Validated KeyID length
This commit is contained in:
DebXWoody
2021-06-28 21:28:58 +02:00
parent 49a0d97a43
commit 2a011e69ac
5 changed files with 73 additions and 43 deletions

View File

@@ -1454,39 +1454,41 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
message->enc = PROF_MSG_ENC_OX;
#ifdef HAVE_LIBGPGME
xmpp_ctx_t* const ctx = connection_get_ctx();
xmpp_stanza_t* ox = xmpp_stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
if (!ox) {
return;
}
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");
if ( !p ) {
log_warning("OX Stanza - no Payload");
return;
}
xmpp_stanza_t *b = xmpp_stanza_get_child_by_name(p, "body");
if ( !b ) {
log_warning("OX Stanza - no body");
return;
}
message->plain = xmpp_stanza_get_text(b);
if(message->plain == NULL ) {
message->plain = xmpp_stanza_get_text(stanza);
}
message->encrypted = xmpp_stanza_get_text(ox);
char* ox_text = xmpp_stanza_get_text(ox);
if (!ox_text) {
return;
}
message->plain = p_ox_gpg_decrypt(ox_text);
xmpp_free(ctx, ox_text);
xmpp_stanza_t *x = xmpp_stanza_new_from_string(ctx, message->plain);
xmpp_stanza_t *p = xmpp_stanza_get_child_by_name(x, "payload");
if (p) {
xmpp_stanza_t *b = xmpp_stanza_get_child_by_name(p, "body");
if (b) {
message->plain = xmpp_stanza_get_text(b);
if(message->plain == NULL ) {
message->plain = xmpp_stanza_get_text(stanza);
if (message->plain == NULL) {
message->plain = xmpp_stanza_get_text(stanza);
}
message->encrypted = xmpp_stanza_get_text(ox);
} else {
log_warning("OX Stanza text to stanza failed");
}
message->encrypted = xmpp_stanza_get_text(ox);
if (message->plain == NULL) {
message->plain = xmpp_stanza_get_text(stanza);
}
message->encrypted = xmpp_stanza_get_text(ox);
}
} else {
log_warning("OX Stanza without openpgp stanza");
}
#endif // HAVE_LIBGPGME
}
static gboolean