feat: Only add envelope elements that should be encrypted

This commit is contained in:
PapaTutuWawa 2023-01-23 13:10:07 +01:00
parent c9c45baabc
commit 72099dfde5

View File

@ -459,9 +459,25 @@ abstract class BaseOmemoManager extends XmppManagerBase {
); );
} }
final envelopeChildren = envelope.firstTag('content')?.children;
if (envelopeChildren != null) {
children.addAll( children.addAll(
envelope.firstTag('content')!.children, envelopeChildren
// Do not add forbidden elements from the envelope
.where((XMLNode child) {
for (final ignore in _doNotEncryptList) {
final xmlns = child.attributes['xmlns'] ?? '';
if (child.tag == ignore.tag && xmlns == ignore.xmlns) {
return false;
}
}
return true;
}),
); );
} else {
logger.warning('Invalid envelope element: No <content /> element');
}
if (!checkAffixElements(envelope, stanza.from!, ourJid)) { if (!checkAffixElements(envelope, stanza.from!, ourJid)) {
other['encryption_error'] = InvalidAffixElementsException(); other['encryption_error'] = InvalidAffixElementsException();