Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect isEncrypted:false if supplied in notify: command, and ensure the correct value is always transmitted onwards #1983

Merged
merged 14 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ class ResourceManager {
commandBody =
'${AtConstants.sharedKeyEncrypted}:${atNotification.atMetadata!.sharedKeyEnc}:$commandBody';
}
if (atNotification.atMetadata!.isEncrypted != null &&
atNotification.atMetadata!.isEncrypted == true) {
commandBody = '${AtConstants.isEncrypted}:true:$commandBody';
}

String? isEncryptedStr =
(atNotification.atMetadata!.isEncrypted ?? false) ? 'true' : 'false';
commandBody = '${AtConstants.isEncrypted}:$isEncryptedStr:$commandBody';

Copy link
Contributor Author

@gkc gkc Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above change is to ensure that the isEncrypted value in the notification's metadata is always passed on to the next atServer. Previously it was only passed on if the value was true

if (atMetaData.ttr != null) {
commandBody =
'ttr:${atMetaData.ttr}:ccd:${atMetaData.isCascade}:$commandBody';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,16 @@ class NotifyVerbHandler extends AbstractVerbHandler {
MessageType messageType, String key, String? isEncryptedStr) {
if (messageType == MessageType.key && key.startsWith('public')) {
return false;
} else if (messageType == MessageType.text) {
}
if (messageType == MessageType.text) {
return SecondaryUtil.getBoolFromString(isEncryptedStr);
} else {
return true;
}
// respect the 'false' value if one was supplied
if (isEncryptedStr != null && isEncryptedStr.toLowerCase() == 'false') {
return false;
}
// At this point, has to return true for legacy reasons. See #1944
return true;
}

String _getFullFormedAtKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void main() async {
'id:1234:update:messageType:key:notifier:system'
':ttln:$ttln'
':ttr:1:ccd:true'
':isEncrypted:false'
':sharedKeyEnc:abc:pubKeyCS:123'
':encKeyName:ekn:encAlgo:ea:ivNonce:ivn'
':skeEncKeyName:ske_ekn:skeEncAlgo:ske_ea'
Expand Down