mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 07:06:21 +00:00
fix(jid): treat NULL/empty/"(null)" barejid the same as resource
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) {
|
if (safe_rid) {
|
||||||
g_string_append_printf(meta, "|corrects:%s", 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);
|
auto_gchar gchar* safe_to = ff_escape_meta_value(to_jid);
|
||||||
g_string_append_printf(meta, "|to:%s", safe_to);
|
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
|
// Build sender — escape ": " in the resource part to prevent
|
||||||
// the parser from splitting at the wrong point.
|
// 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
|
if (from_resource && strlen(from_resource) > 0
|
||||||
&& g_strcmp0(from_resource, "(null)") != 0) {
|
&& g_strcmp0(from_resource, "(null)") != 0) {
|
||||||
// Escape backslash and colon-space in resource
|
// 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
|
// NULL, empty, or the literal "(null)" (legacy artefact from earlier
|
||||||
// builds where g_strdup_printf("%s", NULL) leaked the glibc placeholder
|
// 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) {
|
if (!resource || !*resource || g_strcmp0(resource, "(null)") == 0) {
|
||||||
return jid_create(barejid);
|
return jid_create(barejid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user