ignore other empty buffers which should be null after protobuf decode

pull/1217/head
Audric Ackermann 5 years ago
parent 26e3eca1a2
commit 2257420523
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -370,7 +370,12 @@ export async function innerHandleContentMessage(
} }
if (content.dataMessage) { if (content.dataMessage) {
// Are we not supposed to await here? if (
content.dataMessage.profileKey &&
content.dataMessage.profileKey.length === 0
) {
content.dataMessage.profileKey = null;
}
await handleDataMessage(envelope, content.dataMessage); await handleDataMessage(envelope, content.dataMessage);
return; return;
} }
@ -387,6 +392,12 @@ export async function innerHandleContentMessage(
return; return;
} }
if (content.typingMessage) { if (content.typingMessage) {
if (
content.typingMessage.groupId &&
content.typingMessage.groupId.length === 0
) {
content.typingMessage.groupId = null;
}
await handleTypingMessage(envelope, content.typingMessage); await handleTypingMessage(envelope, content.typingMessage);
return; return;
} }

@ -83,9 +83,10 @@ function cleanAttachment(attachment: any) {
..._.omit(attachment, 'thumbnail'), ..._.omit(attachment, 'thumbnail'),
id: attachment.id.toString(), id: attachment.id.toString(),
key: attachment.key ? StringUtils.decode(attachment.key, 'base64') : null, key: attachment.key ? StringUtils.decode(attachment.key, 'base64') : null,
digest: attachment.digest digest:
? StringUtils.decode(attachment.digest, 'base64') attachment.digest && attachment.digest.length > 0
: null, ? StringUtils.decode(attachment.digest, 'base64')
: null,
}; };
} }
@ -138,7 +139,7 @@ function cleanAttachments(decrypted: any) {
quote.attachments = (quote.attachments || []).map((item: any) => { quote.attachments = (quote.attachments || []).map((item: any) => {
const { thumbnail } = item; const { thumbnail } = item;
if (!thumbnail) { if (!thumbnail || thumbnail.length === 0) {
return item; return item;
} }

@ -215,6 +215,10 @@ function parseContacts(arrbuf: ArrayBuffer): Array<any> {
new Uint8Array(nextBuffer) new Uint8Array(nextBuffer)
); );
if (proto.profileKey && proto.profileKey.length === 0) {
proto.profileKey = null;
}
buffer.skip(len); buffer.skip(len);
if (proto.avatar) { if (proto.avatar) {
@ -259,7 +263,7 @@ export async function handleContacts(
window.log.info('contact sync'); window.log.info('contact sync');
// const { blob } = contacts; // const { blob } = contacts;
if (!contacts.data) { if (!contacts.data || contacts.data.length === 0) {
window.log.error('Contacts without data'); window.log.error('Contacts without data');
return; return;
} }

@ -48,7 +48,6 @@ interface ReqOptions {
const incomingMessagePromises: Array<Promise<any>> = []; const incomingMessagePromises: Array<Promise<any>> = [];
async function handleEnvelope(envelope: EnvelopePlus) { async function handleEnvelope(envelope: EnvelopePlus) {
const { textsecure } = window;
// TODO: enable below // TODO: enable below
// if (this.stoppingProcessing) { // if (this.stoppingProcessing) {
@ -59,7 +58,7 @@ async function handleEnvelope(envelope: EnvelopePlus) {
return onDeliveryReceipt(envelope.source, envelope.timestamp); return onDeliveryReceipt(envelope.source, envelope.timestamp);
} }
if (envelope.content) { if (envelope.content && envelope.content.length > 0) {
return handleContentMessage(envelope); return handleContentMessage(envelope);
} }

Loading…
Cancel
Save