fix(jid): treat NULL/empty/"(null)" resource as bare jid
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 13m44s
CI Code / Check spelling (pull_request) Failing after 14m13s
CI Code / Check coding style (pull_request) Failing after 14m43s
CI Code / Linux (ubuntu) (pull_request) Failing after 15m16s
CI Code / Linux (debian) (pull_request) Failing after 15m53s
CI Code / Linux (arch) (pull_request) Failing after 16m23s
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 13m44s
CI Code / Check spelling (pull_request) Failing after 14m13s
CI Code / Check coding style (pull_request) Failing after 14m43s
CI Code / Linux (ubuntu) (pull_request) Failing after 15m16s
CI Code / Linux (debian) (pull_request) Failing after 15m53s
CI Code / Linux (arch) (pull_request) Failing after 16m23s
This commit is contained in:
@@ -469,7 +469,8 @@ ff_write_line(FILE* fp, const char* timestamp, const char* type, const char* enc
|
||||
auto_gchar gchar* safe_to = ff_escape_meta_value(to_jid);
|
||||
g_string_append_printf(meta, "|to:%s", safe_to);
|
||||
}
|
||||
if (to_resource && strlen(to_resource) > 0) {
|
||||
if (to_resource && strlen(to_resource) > 0
|
||||
&& g_strcmp0(to_resource, "(null)") != 0) {
|
||||
auto_gchar gchar* safe_tores = ff_escape_meta_value(to_resource);
|
||||
g_string_append_printf(meta, "|to_res:%s", safe_tores);
|
||||
}
|
||||
@@ -481,7 +482,8 @@ 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");
|
||||
if (from_resource && strlen(from_resource) > 0) {
|
||||
if (from_resource && strlen(from_resource) > 0
|
||||
&& g_strcmp0(from_resource, "(null)") != 0) {
|
||||
// Escape backslash and colon-space in resource
|
||||
GString* safe_res = g_string_sized_new(strlen(from_resource));
|
||||
for (const char* p = from_resource; *p; p++) {
|
||||
|
||||
@@ -111,6 +111,12 @@ jid_create(const gchar* const str)
|
||||
Jid*
|
||||
jid_create_from_bare_and_resource(const char* const barejid, const char* const resource)
|
||||
{
|
||||
// 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.
|
||||
if (!resource || !*resource || g_strcmp0(resource, "(null)") == 0) {
|
||||
return jid_create(barejid);
|
||||
}
|
||||
auto_char char* jid = create_fulljid(barejid, resource);
|
||||
return jid_create(jid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user