fix(jid): treat NULL/empty/"(null)" barejid the same as resource
Some checks failed
CI Code / Check spelling (pull_request) Successful in 2m0s
CI Code / Check coding style (pull_request) Failing after 2m10s
CI Code / Linux (debian) (pull_request) Successful in 8m29s
CI Code / Linux (ubuntu) (pull_request) Successful in 8m33s
CI Code / Code Coverage (pull_request) Successful in 6m50s
CI Code / Linux (arch) (pull_request) Successful in 10m30s

This commit is contained in:
2026-05-04 18:52:39 +03:00
parent 3daee1216b
commit b8a4900393
2 changed files with 11 additions and 3 deletions

View File

@@ -465,7 +465,8 @@ ff_write_line(FILE* fp, const char* timestamp, const char* type, const char* enc
if (safe_rid) {
g_string_append_printf(meta, "|corrects:%s", safe_rid);
}
if (to_jid && strlen(to_jid) > 0) {
if (to_jid && strlen(to_jid) > 0
&& g_strcmp0(to_jid, "(null)") != 0) {
auto_gchar gchar* safe_to = ff_escape_meta_value(to_jid);
g_string_append_printf(meta, "|to:%s", safe_to);
}
@@ -481,7 +482,9 @@ ff_write_line(FILE* fp, const char* timestamp, const char* type, const char* enc
// Build sender — escape ": " in the resource part to prevent
// the parser from splitting at the wrong point.
GString* sender = g_string_new(from_jid ? from_jid : "unknown");
const gboolean from_jid_usable = from_jid && *from_jid
&& g_strcmp0(from_jid, "(null)") != 0;
GString* sender = g_string_new(from_jid_usable ? from_jid : "unknown");
if (from_resource && strlen(from_resource) > 0
&& g_strcmp0(from_resource, "(null)") != 0) {
// Escape backslash and colon-space in resource

View File

@@ -113,7 +113,12 @@ jid_create_from_bare_and_resource(const char* const barejid, const char* const r
{
// NULL, empty, or the literal "(null)" (legacy artefact from earlier
// builds where g_strdup_printf("%s", NULL) leaked the glibc placeholder
// into stored resourceparts) all mean "no resource" — return a bare jid.
// into stored data) all mean "no value" for either part. With no usable
// bare jid there is nothing to construct; with no usable resource we
// return the bare jid alone.
if (!barejid || !*barejid || g_strcmp0(barejid, "(null)") == 0) {
return NULL;
}
if (!resource || !*resource || g_strcmp0(resource, "(null)") == 0) {
return jid_create(barejid);
}