Compare commits
1 Commits
92f601d2ea
...
1fe3808b23
| Author | SHA1 | Date | |
|---|---|---|---|
|
1fe3808b23
|
@@ -145,7 +145,7 @@ _ff_maybe_index_line(ff_contact_state_t* state, const char* buf, off_t pos)
|
||||
char* ts_str = g_strndup(buf, space - buf);
|
||||
GDateTime* dt = g_date_time_new_from_iso8601(ts_str, NULL);
|
||||
if (!dt) {
|
||||
log_warning("flatfile: unparseable timestamp in %s at offset %ld: %s",
|
||||
log_warning("flatfile: unparsable timestamp in %s at offset %ld: %s",
|
||||
state->filepath, (long)pos, ts_str);
|
||||
g_free(ts_str);
|
||||
return;
|
||||
|
||||
@@ -64,8 +64,8 @@ typedef struct
|
||||
|
||||
// --- Metadata field prefixes (used in _ff_cache_line_ids and ff_parse_line) ---
|
||||
|
||||
#define FF_META_PREFIX_ID "id:"
|
||||
#define FF_META_PREFIX_AID "aid:"
|
||||
#define FF_META_PREFIX_ID "id:"
|
||||
#define FF_META_PREFIX_AID "aid:"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -77,8 +77,8 @@ _collect_contact_dirs(const gchar* const contact_barejid, GSList** issues)
|
||||
contact_dirs = g_slist_prepend(contact_dirs, g_strdup(cdir));
|
||||
} else {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_INFO, contact_barejid, 0,
|
||||
g_strdup("No log files found for this contact")));
|
||||
_issue_new(INTEGRITY_INFO, contact_barejid, 0,
|
||||
g_strdup("No log files found for this contact")));
|
||||
}
|
||||
return contact_dirs;
|
||||
}
|
||||
@@ -117,9 +117,9 @@ _check_permissions(const char* filepath, const char* basename, GSList** issues)
|
||||
if ((st.st_mode & 0777) == (S_IRUSR | S_IWUSR))
|
||||
return;
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, 0,
|
||||
g_strdup_printf("File permissions are %o, expected 600 (sensitive data)",
|
||||
st.st_mode & 0777)));
|
||||
_issue_new(INTEGRITY_WARNING, basename, 0,
|
||||
g_strdup_printf("File permissions are %o, expected 600 (sensitive data)",
|
||||
st.st_mode & 0777)));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -144,8 +144,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
{
|
||||
if (ff_skip_bom(fp)) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_INFO, basename, 0,
|
||||
g_strdup("File has UTF-8 BOM — harmless but unnecessary")));
|
||||
_issue_new(INTEGRITY_INFO, basename, 0,
|
||||
g_strdup("File has UTF-8 BOM — harmless but unnecessary")));
|
||||
}
|
||||
|
||||
char* buf = NULL;
|
||||
@@ -172,8 +172,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
const gchar* end;
|
||||
if (!g_utf8_validate(buf, -1, &end)) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup_printf("Invalid UTF-8 at byte offset %ld", (long)(end - buf))));
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup_printf("Invalid UTF-8 at byte offset %ld", (long)(end - buf))));
|
||||
free(buf);
|
||||
continue;
|
||||
}
|
||||
@@ -182,8 +182,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
unsigned char ch = (unsigned char)buf[i];
|
||||
if (ch < 0x20 && ch != '\t') {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Contains control character 0x%02x", ch)));
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Contains control character 0x%02x", ch)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -191,8 +191,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
ff_parsed_line_t* pl = ff_parse_line(buf);
|
||||
if (!pl) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup("Unparsable line")));
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup("Unparsable line")));
|
||||
free(buf);
|
||||
continue;
|
||||
}
|
||||
@@ -202,8 +202,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
auto_gchar gchar* ts_cur = g_date_time_format_iso8601(pl->timestamp);
|
||||
auto_gchar gchar* ts_prev = g_date_time_format_iso8601(prev_ts);
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Timestamp out of order (%s after %s)", ts_cur, ts_prev)));
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Timestamp out of order (%s after %s)", ts_cur, ts_prev)));
|
||||
}
|
||||
if (prev_ts)
|
||||
g_date_time_unref(prev_ts);
|
||||
@@ -212,8 +212,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
if (pl->stanza_id && pl->stanza_id[0] != '\0') {
|
||||
if (g_hash_table_contains(seen_stanza_ids, pl->stanza_id)) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Duplicate stanza-id \"%s\"", pl->stanza_id)));
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Duplicate stanza-id \"%s\"", pl->stanza_id)));
|
||||
} else {
|
||||
g_hash_table_insert(seen_stanza_ids, g_strdup(pl->stanza_id), GINT_TO_POINTER(lineno));
|
||||
}
|
||||
@@ -222,8 +222,8 @@ _first_pass(FILE* fp, const char* basename,
|
||||
if (pl->archive_id && pl->archive_id[0] != '\0') {
|
||||
if (g_hash_table_contains(seen_archive_ids, pl->archive_id)) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Duplicate archive-id \"%s\"", pl->archive_id)));
|
||||
_issue_new(INTEGRITY_WARNING, basename, lineno,
|
||||
g_strdup_printf("Duplicate archive-id \"%s\"", pl->archive_id)));
|
||||
} else {
|
||||
g_hash_table_insert(seen_archive_ids, g_strdup(pl->archive_id), GINT_TO_POINTER(lineno));
|
||||
}
|
||||
@@ -237,13 +237,13 @@ _first_pass(FILE* fp, const char* basename,
|
||||
|
||||
if (has_crlf) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_WARNING, basename, 0,
|
||||
g_strdup("File uses Windows line endings (CRLF) — consider converting to LF")));
|
||||
_issue_new(INTEGRITY_WARNING, basename, 0,
|
||||
g_strdup("File uses Windows line endings (CRLF) — consider converting to LF")));
|
||||
}
|
||||
if (is_empty) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_INFO, basename, 0,
|
||||
g_strdup("File is empty (no message lines)")));
|
||||
_issue_new(INTEGRITY_INFO, basename, 0,
|
||||
g_strdup("File is empty (no message lines)")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +281,9 @@ _lmc_pass(FILE* fp, const char* basename, GHashTable* all_stanza_ids, GSList** i
|
||||
if (pl->replace_id && pl->replace_id[0] != '\0'
|
||||
&& !g_hash_table_contains(all_stanza_ids, pl->replace_id)) {
|
||||
*issues = g_slist_prepend(*issues,
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup_printf("Broken correction reference: corrects:%s not found",
|
||||
pl->replace_id)));
|
||||
_issue_new(INTEGRITY_ERROR, basename, lineno,
|
||||
g_strdup_printf("Broken correction reference: corrects:%s not found",
|
||||
pl->replace_id)));
|
||||
}
|
||||
ff_parsed_line_free(pl);
|
||||
}
|
||||
@@ -344,8 +344,8 @@ ff_verify_integrity(const gchar* const contact_barejid)
|
||||
|
||||
if (!g_flatfile_account_jid) {
|
||||
issues = g_slist_prepend(issues,
|
||||
_issue_new(INTEGRITY_ERROR, "N/A", 0,
|
||||
g_strdup("Flat-file backend not initialized")));
|
||||
_issue_new(INTEGRITY_ERROR, "N/A", 0,
|
||||
g_strdup("Flat-file backend not initialized")));
|
||||
return issues;
|
||||
}
|
||||
|
||||
|
||||
@@ -893,7 +893,7 @@ test_stress_mixed_types_and_encodings(void** state)
|
||||
/* Parse and verify type/enc distribution */
|
||||
fp = fopen(tmppath, "r");
|
||||
assert_non_null(fp);
|
||||
int counts[3] = { 0 }; /* chat, muc, mucpm */
|
||||
int counts[3] = { 0 }; /* chat, muc, mucpm */
|
||||
int enc_counts[5] = { 0 }; /* none, omemo, otr, pgp, ox */
|
||||
int parsed = 0;
|
||||
|
||||
@@ -911,15 +911,23 @@ test_stress_mixed_types_and_encodings(void** state)
|
||||
continue;
|
||||
parsed++;
|
||||
|
||||
if (g_strcmp0(pl->type, "chat") == 0) counts[0]++;
|
||||
else if (g_strcmp0(pl->type, "muc") == 0) counts[1]++;
|
||||
else if (g_strcmp0(pl->type, "mucpm") == 0) counts[2]++;
|
||||
if (g_strcmp0(pl->type, "chat") == 0)
|
||||
counts[0]++;
|
||||
else if (g_strcmp0(pl->type, "muc") == 0)
|
||||
counts[1]++;
|
||||
else if (g_strcmp0(pl->type, "mucpm") == 0)
|
||||
counts[2]++;
|
||||
|
||||
if (g_strcmp0(pl->enc, "none") == 0) enc_counts[0]++;
|
||||
else if (g_strcmp0(pl->enc, "omemo") == 0) enc_counts[1]++;
|
||||
else if (g_strcmp0(pl->enc, "otr") == 0) enc_counts[2]++;
|
||||
else if (g_strcmp0(pl->enc, "pgp") == 0) enc_counts[3]++;
|
||||
else if (g_strcmp0(pl->enc, "ox") == 0) enc_counts[4]++;
|
||||
if (g_strcmp0(pl->enc, "none") == 0)
|
||||
enc_counts[0]++;
|
||||
else if (g_strcmp0(pl->enc, "omemo") == 0)
|
||||
enc_counts[1]++;
|
||||
else if (g_strcmp0(pl->enc, "otr") == 0)
|
||||
enc_counts[2]++;
|
||||
else if (g_strcmp0(pl->enc, "pgp") == 0)
|
||||
enc_counts[3]++;
|
||||
else if (g_strcmp0(pl->enc, "ox") == 0)
|
||||
enc_counts[4]++;
|
||||
|
||||
ff_parsed_line_free(pl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user