msg b64: base64-encode display prefix in d-field to avoid pipe/quote breaking parse
b64_encode/decode (URL-safe A-Za-z0-9-_) in chat_core_priv.h on_media_registered encodes msg_data before full_data on_msg_inserted/chat_core_attachment_download decode base_filename android_jni_bridge decodes prefix for UI display
This commit is contained in:
1 parent
6a02a16543
commit
ea6eeae210
3 files changed
+76
-1
No files matched your search
@@ -413,6 +413,19 @@ char* utun_bridge_get_messages_json(const char* channel_id, int limit) {
|
||||
const char* cts = strstr((const char*)dptr, "\"ct\":\"");
|
||||
if (cts) { cts += 6; char* cte = strchr((char*)cts, '"'); if (cte) { size_t tlc = (size_t)(cte - cts); if (tlc < sizeof(ct)) { memcpy(ct, cts, tlc); ct[tlc] = '\0'; } } }
|
||||
}
|
||||
/* base64-decode display prefix for media messages (encoded in on_media_registered) */
|
||||
if (strcmp(ct, "text/plain") != 0 && txt[0]) {
|
||||
char* pipe = strchr(txt, '|');
|
||||
if (pipe) {
|
||||
size_t prefix_len = (size_t)(pipe - txt);
|
||||
uint8_t dec[1024]; int declen = (int)b64_decode(txt, prefix_len, dec, sizeof(dec));
|
||||
if (declen > 0 && declen < 2000) {
|
||||
size_t suffix_len = strlen(pipe);
|
||||
memmove(txt + declen, pipe, suffix_len + 1);
|
||||
memcpy(txt, dec, (size_t)declen);
|
||||
}
|
||||
}
|
||||
}
|
||||
char* esc_txt = json_escape_alloc(txt);
|
||||
char* esc_ct = json_escape_alloc(ct);
|
||||
int is_out = (node_id == (int64_t)my_id) ? 1 : 0;
|
||||
|
||||
Reference in new issue
Block a user