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
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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user