mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Added better support for special caracters in Autotype sequecne (+, ~, ^ and %)
This commit is contained in:
@@ -151,7 +151,6 @@
|
||||
4C77E37315B84A240093A587 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77E37215B84A240093A587 /* main.m */; };
|
||||
4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77E37915B84A240093A587 /* MPAppDelegate.m */; };
|
||||
4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; };
|
||||
4C7931031D0F053900A511E8 /* MPTestNodeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C7931021D0F053900A511E8 /* MPTestNodeDelegate.m */; };
|
||||
4C7931061D0F0B0800A511E8 /* MPNodeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C7931051D0F0B0800A511E8 /* MPNodeDelegate.m */; };
|
||||
4C7ABA4817BAEC6700FF5799 /* 15_ScannerTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C7ABA4317BAEC6700FF5799 /* 15_ScannerTemplate.pdf */; };
|
||||
4C7ABA4917BAEC6700FF5799 /* 16_BrowserTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C7ABA4417BAEC6700FF5799 /* 16_BrowserTemplate.pdf */; };
|
||||
@@ -203,7 +202,6 @@
|
||||
4CC6DB7A17D23719002C6091 /* KPKNode+IconImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6DB7917D23719002C6091 /* KPKNode+IconImage.m */; };
|
||||
4CCA8E9B18D91ED9001A6754 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CCA8E9A18D91ED9001A6754 /* Quartz.framework */; };
|
||||
4CCCD83E1C8DFF20002B77B6 /* MPEntryProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCCD83D1C8DFF20002B77B6 /* MPEntryProxy.m */; };
|
||||
4CCCD8401C8E02FE002B77B6 /* MPTextEntryProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCCD83F1C8E02FE002B77B6 /* MPTextEntryProxy.m */; };
|
||||
4CCEDE2A179F203B008402BE /* MPOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE29179F203B008402BE /* MPOutlineView.m */; };
|
||||
4CCEDE2E179F213B008402BE /* MPNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE2D179F213B008402BE /* MPNotifications.m */; };
|
||||
4CCFA13D1BF0CC7A0078E0A1 /* Test_Password_1234.kdb in Resources */ = {isa = PBXBuildFile; fileRef = 4CCFA1321BF0CC7A0078E0A1 /* Test_Password_1234.kdb */; };
|
||||
@@ -516,7 +514,6 @@
|
||||
4C77E37415B84A240093A587 /* MacPass-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MacPass-Prefix.pch"; sourceTree = "<group>"; };
|
||||
4C77E37815B84A240093A587 /* MPAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPAppDelegate.h; sourceTree = "<group>"; };
|
||||
4C77E37915B84A240093A587 /* MPAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPAppDelegate.m; sourceTree = "<group>"; };
|
||||
4C7931021D0F053900A511E8 /* MPTestNodeDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestNodeDelegate.m; sourceTree = "<group>"; };
|
||||
4C7931041D0F0B0800A511E8 /* MPNodeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNodeDelegate.h; sourceTree = "<group>"; };
|
||||
4C7931051D0F0B0800A511E8 /* MPNodeDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNodeDelegate.m; sourceTree = "<group>"; };
|
||||
4C7ABA4317BAEC6700FF5799 /* 15_ScannerTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 15_ScannerTemplate.pdf; sourceTree = "<group>"; };
|
||||
@@ -605,7 +602,6 @@
|
||||
4CCA8E9A18D91ED9001A6754 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
|
||||
4CCCD83C1C8DFF20002B77B6 /* MPEntryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryProxy.h; sourceTree = "<group>"; };
|
||||
4CCCD83D1C8DFF20002B77B6 /* MPEntryProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryProxy.m; sourceTree = "<group>"; };
|
||||
4CCCD83F1C8E02FE002B77B6 /* MPTextEntryProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTextEntryProxy.m; sourceTree = "<group>"; };
|
||||
4CCEDE28179F203B008402BE /* MPOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineView.h; sourceTree = "<group>"; };
|
||||
4CCEDE29179F203B008402BE /* MPOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineView.m; sourceTree = "<group>"; };
|
||||
4CCEDE2C179F2122008402BE /* MPNotifications.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPNotifications.h; sourceTree = "<group>"; };
|
||||
@@ -986,8 +982,6 @@
|
||||
4C45FB2C178E0BCB0010007D /* MPDatabaseLoading.m */,
|
||||
4C45FB2F178E0CE20010007D /* MPTestDocument.m */,
|
||||
4C6BC65F1A36717E00BDDF3D /* MPDatabaseSearch.m */,
|
||||
4CCCD83F1C8E02FE002B77B6 /* MPTextEntryProxy.m */,
|
||||
4C7931021D0F053900A511E8 /* MPTestNodeDelegate.m */,
|
||||
4C45FB1F178E09ED0010007D /* Supporting Files */,
|
||||
);
|
||||
path = MacPassTests;
|
||||
@@ -1672,9 +1666,7 @@
|
||||
files = (
|
||||
4C45FB2D178E0BCB0010007D /* MPDatabaseLoading.m in Sources */,
|
||||
4C8DEAA21C314D2C00D24C32 /* MPTestAutotypeDelay.m in Sources */,
|
||||
4C7931031D0F053900A511E8 /* MPTestNodeDelegate.m in Sources */,
|
||||
4C45FB30178E0CE20010007D /* MPTestDocument.m in Sources */,
|
||||
4CCCD8401C8E02FE002B77B6 /* MPTextEntryProxy.m in Sources */,
|
||||
4C6BC6601A36717E00BDDF3D /* MPDatabaseSearch.m in Sources */,
|
||||
4C10207F1B750E2F00BFCD59 /* MPTestAutotype.m in Sources */,
|
||||
);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPInspectorViewController">
|
||||
<connections>
|
||||
<outlet property="bottomBar" destination="2930" id="2995"/>
|
||||
<outlet property="cancelEditButton" destination="3126" id="3141"/>
|
||||
<outlet property="editButton" destination="3109" id="3122"/>
|
||||
<outlet property="itemImageView" destination="2998" id="3024"/>
|
||||
<outlet property="itemNameTextField" destination="3013" id="3025"/>
|
||||
@@ -34,33 +33,11 @@
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3126">
|
||||
<rect key="frame" x="154" y="2" width="57" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3127">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancelChangesToSelectedItem:" target="-1" id="Hg9-6o-dRD"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button hidden="YES" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jBD-3D-knW">
|
||||
<rect key="frame" x="20" y="2" width="59" height="25"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="History" bezelStyle="texturedRounded" alignment="center" enabled="NO" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="w1z-1n-b0m">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="showHistory:" target="-1" id="Ay6-cl-onN"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="2949"/>
|
||||
<constraint firstItem="3126" firstAttribute="baseline" secondItem="3109" secondAttribute="baseline" id="3129"/>
|
||||
<constraint firstAttribute="trailing" secondItem="3109" secondAttribute="trailing" constant="20" symbolic="YES" id="3138"/>
|
||||
<constraint firstItem="3109" firstAttribute="centerY" secondItem="2930" secondAttribute="centerY" id="3139"/>
|
||||
<constraint firstItem="3109" firstAttribute="leading" secondItem="3126" secondAttribute="trailing" constant="8" symbolic="YES" id="3140"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="2998" customClass="MPPopupImageView">
|
||||
|
||||
@@ -75,6 +75,26 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F
|
||||
});
|
||||
return keypressCommands;
|
||||
}
|
||||
/* Commands that are actually just one symbol to be pasted */
|
||||
+ (NSDictionary *)pasteableCommands {
|
||||
static NSDictionary *pasteableCommands;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
pasteableCommands = @{
|
||||
kKPKAutotypePlus: @"+",
|
||||
kKPKAutotypeOr: @"^",
|
||||
kKPKAutotypePercent: @"%",
|
||||
kKPKAutotypeTilde : @"~",
|
||||
kKPKAutotypeRoundBracketLeft : @"(",
|
||||
kKPKAutotypeRoundBracketRight : @")",
|
||||
kKPKAutotypeSquareBracketLeft : @"[",
|
||||
kKPKAutotypeSquareBracketRight : @"]",
|
||||
kKPKAutotypeCurlyBracketLeft: @"{",
|
||||
kKPKAutotypeCurlyBracketRight: @"}"
|
||||
};
|
||||
});
|
||||
return pasteableCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping for modifier to CGEventFlags.
|
||||
@@ -112,7 +132,7 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F
|
||||
NSUInteger lastLocation = 0;
|
||||
CGEventFlags collectedModifers = 0;
|
||||
for(NSValue *rangeValue in commandRanges) {
|
||||
NSRange commandRange = [rangeValue rangeValue];
|
||||
NSRange commandRange = rangeValue.rangeValue;
|
||||
/* All non-commands will get translated into paste commands */
|
||||
if(commandRange.location > lastLocation) {
|
||||
/* If there were modifiers we need to use the next single stroke and update the modifier command */
|
||||
@@ -268,6 +288,13 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F
|
||||
[commands addObject:[[MPAutotypeKeyPress alloc] initWithModifierMask:flags keyCode:keyCode]];
|
||||
return; // Done
|
||||
}
|
||||
/* {PLUS}, {TILDE}, {PERCENT}, {+}, etc */
|
||||
NSString *pasteConent = [self pasteableCommands][uppercaseCommand];
|
||||
if(pasteConent) {
|
||||
[self appendAppropriatePasteCommandForEntry:entry withContent:pasteConent toCommands:commands];
|
||||
return; // Done
|
||||
}
|
||||
|
||||
/* F1-16 */
|
||||
NSRegularExpression *functionKeyRegExp = [[NSRegularExpression alloc] initWithPattern:kKPKAutotypeFunctionMaskRegularExpression options:NSRegularExpressionCaseInsensitive error:0];
|
||||
NSTextCheckingResult *functionResult = [functionKeyRegExp firstMatchInString:commandString options:0 range:NSMakeRange(0, commandString.length)];
|
||||
@@ -321,6 +348,7 @@ static CGKeyCode kMPFunctionKeyCodes[] = { kVK_F1, kVK_F2, kVK_F3, kVK_F4, kVK_F
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Fallback */
|
||||
[self appendAppropriatePasteCommandForEntry:entry withContent:commandString toCommands:commands];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,30 +64,31 @@ uint16_t const kMPUnknownKeyCode = UINT16_MAX;
|
||||
NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(currentKeyboard, kTISPropertyLocalizedName);
|
||||
CFRelease(currentKeyboard);
|
||||
|
||||
/* Initalize the keyboardCodeDictonary */
|
||||
if(keyboardCodeDictionary == nil) {
|
||||
/* Input source should not change that much while we are running */
|
||||
keyboardCodeDictionary = [[NSMutableDictionary alloc] initWithCapacity:2];
|
||||
}
|
||||
NSDictionary *charToCodeDict = keyboardCodeDictionary[localizedName];
|
||||
if(nil == keyboardCodeDictionary[localizedName]) {
|
||||
/* We need 128 places for this dict */
|
||||
charToCodeDict = [[NSMutableDictionary alloc] initWithCapacity:128];
|
||||
/* search for current character mapping */
|
||||
NSDictionary<NSString *, NSNumber *> *charToCodeDict = keyboardCodeDictionary[localizedName];
|
||||
|
||||
if(nil == charToCodeDict) {
|
||||
/* Add mapping */
|
||||
NSMutableDictionary *tempCharToCodeDict = [[NSMutableDictionary alloc] initWithCapacity:128];
|
||||
|
||||
/* Generate table of keycodes and characters. */
|
||||
/* Loop through every keycode (0 - 127) to find its current mapping. */
|
||||
for(CGKeyCode keyCode = 0; keyCode < 128; ++keyCode) {
|
||||
NSString *string = [self stringForKey:keyCode];
|
||||
if(string != nil) {
|
||||
((NSMutableDictionary *)charToCodeDict)[string] = @(keyCode);
|
||||
tempCharToCodeDict[string] = @(keyCode);
|
||||
}
|
||||
}
|
||||
keyboardCodeDictionary[localizedName] = [[NSDictionary alloc] initWithDictionary:charToCodeDict];
|
||||
keyboardCodeDictionary[localizedName] = [[NSDictionary alloc] initWithDictionary:tempCharToCodeDict];
|
||||
}
|
||||
/* Add mapping */
|
||||
/* Generate table of keycodes and characters. */
|
||||
|
||||
NSString *singleCharacter = [[character substringToIndex:1] lowercaseString];
|
||||
NSString *singleCharacter = [character substringToIndex:1].lowercaseString;
|
||||
if(charToCodeDict[singleCharacter]) {
|
||||
return [charToCodeDict[singleCharacter] integerValue];
|
||||
return charToCodeDict[singleCharacter].integerValue;
|
||||
}
|
||||
return kMPUnknownKeyCode;
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// MPTestNodeDelegate.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 13/06/16.
|
||||
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <KeePassKit/KeePassKit.h>
|
||||
|
||||
@interface MPDummyDelegate : NSObject <KPKModificationDelegate>
|
||||
|
||||
@property (strong) NSMutableSet<NSUUID *> *uuids;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPDummyDelegate
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self.uuids = [[NSMutableSet alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)willModifyNode:(KPKNode *)node {
|
||||
if(node.asGroup || ! node.asEntry) {
|
||||
NSLog(@"Node is no entry, no need to do anything!");
|
||||
return;
|
||||
}
|
||||
KPKEntry *entry = node.asEntry;
|
||||
if(![self.uuids containsObject:entry.uuid]) {
|
||||
[self.uuids addObject:entry.uuid];
|
||||
NSLog(@"First mutation for %@ detected. Pushin history", entry);
|
||||
[entry pushHistory];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface MPTestNodeDelegate : XCTestCase
|
||||
|
||||
@property (strong) KPKEntry *entry;
|
||||
@property (strong) MPDummyDelegate *delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPTestNodeDelegate
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
self.entry = [[KPKEntry alloc] init];
|
||||
self.entry.title = @"Entry Title";
|
||||
self.entry.url = @"http://www.internet.com";
|
||||
self.entry.password = @"1234";
|
||||
self.entry.username = @"Entry Username";
|
||||
self.entry.autotype.defaultKeystrokeSequence = @"{TAB 3}";
|
||||
|
||||
self.delegate = [[MPDummyDelegate alloc] init];
|
||||
|
||||
self.entry.delegate = self.delegate;
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testModificationDetection {
|
||||
XCTAssertTrue(self.entry.history.count == 0, @"No History entry is present on newly created entry!");
|
||||
self.entry.password = @"New Password";
|
||||
XCTAssertEqualObjects(self.entry.password, @"New Password", @"Password is set on entry!");
|
||||
XCTAssertTrue(self.entry.history.count == 1, @"Changin the password creates a history entry!");
|
||||
KPKEntry *historyEntry = self.entry.history.firstObject;
|
||||
XCTAssertEqualObjects(historyEntry.password, @"1234", @"Password on history entry did not change!");
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// MPTextEntryProxy.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 07/03/16.
|
||||
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import <KeePassKit/KeePassKit.h>
|
||||
|
||||
#import "MPEntryProxy.h"
|
||||
|
||||
@interface MPTextEntryProxy : XCTestCase
|
||||
@property (strong) KPKEntry *entry;
|
||||
@property (strong) MPEntryProxy *proxy;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPTextEntryProxy
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
self.entry = [[KPKEntry alloc] init];
|
||||
self.entry.title = @"Entry Title";
|
||||
self.entry.url = @"http://www.internet.com";
|
||||
self.entry.password = @"1234";
|
||||
self.entry.username = @"Entry Username";
|
||||
self.entry.autotype.defaultKeystrokeSequence = @"{TAB 3}";
|
||||
|
||||
self.proxy = [[MPEntryProxy alloc] initWithEntry:self.entry];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testMethodForwarding {
|
||||
NSString *newPassword = @"new password";
|
||||
NSString *newKeystrokes = @"{ENTER 3}";
|
||||
[((id)self.proxy) setPassword:newPassword];
|
||||
XCTAssertNotEqualObjects(self.entry.password, newPassword, @"Proxy does not set password on entry!");
|
||||
|
||||
[((id)self.proxy) autotype].defaultKeystrokeSequence= newKeystrokes;
|
||||
XCTAssertEqualObjects(self.entry.autotype.defaultKeystrokeSequence, newKeystrokes, @"Proxy sets default keystroke sequence on entry autotype!");
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user