From 1399a8d1429f2b3bc0b88b04e607dd3c6f0549a3 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 1 Mar 2019 16:01:01 +0100 Subject: [PATCH] documented Autotype context API to make internal behaviour clear --- MacPass/MPAutotypeContext.h | 9 +++++++-- MacPass/MPAutotypeContext.m | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/MacPass/MPAutotypeContext.h b/MacPass/MPAutotypeContext.h index 3cf95711..c4ffbf98 100644 --- a/MacPass/MPAutotypeContext.h +++ b/MacPass/MPAutotypeContext.h @@ -41,11 +41,16 @@ @property (nonatomic, readonly, copy) NSString *command; @property (nonatomic, readonly, copy) NSString *normalizedCommand; /** - * Command with placeholders and references resolved + * Command with placeholders and references resolved. + * This will evaluate any placeholder regardless of side-effects. + * If you need to evaluat the command without interaction, you should call kpk_finalValueForEntry:options: directly on the normalizedCommand. */ @property (nonatomic, readonly, copy) NSString *evaluatedCommand; /** - @return command with placeholders and references resolved but masked password placeholder + @return command with placeholders and references resolved but masked password placeholder. + + This will call kpk_finalValueForEntry:options on the normalizedCommand with options set to KPKCommandEvaluationOptionSkipUserInteraction and KPKCommandEvaluationOptionReadOnly. + This way it is ensured that the value can be used in UI without any intereference or data changes! */ @property (nonatomic, readonly, copy) NSString *maskedEvaluatedCommand; /** diff --git a/MacPass/MPAutotypeContext.m b/MacPass/MPAutotypeContext.m index 278914ab..4ba866b4 100644 --- a/MacPass/MPAutotypeContext.m +++ b/MacPass/MPAutotypeContext.m @@ -86,7 +86,7 @@ NSString *passwordPlaceholder = [NSString stringWithFormat:@"{%@}",kKPKPasswordKey]; NSString *normalized = self.normalizedCommand; NSString *masked = [normalized stringByReplacingOccurrencesOfString:passwordPlaceholder withString:@"•••" options:NSCaseInsensitiveSearch range:NSMakeRange(0, normalized.length)]; - return [[masked kpk_finalValueForEntry:self.entry] copy]; + return [[masked kpk_finalValueForEntry:self.entry options:KPKCommandEvaluationOptionSkipUserInteraction|KPKCommandEvaluationOptionReadOnly] copy]; } - (NSString *)description {