diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 2cca59a41..360412b92 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 56; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -101,6 +101,7 @@ 1146E9EDCF8344F7D6E0D553 /* MockCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0376C429FAB1687C3D905F3E /* MockCoder.swift */; }; 119AE9A3FC6E0606C1146528 /* NotificationSettingsEditScreenRoomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97F8963B14EB0AF3940DDBF /* NotificationSettingsEditScreenRoomCell.swift */; }; 11A6B8E3CBDBF0A4107FF4CE /* OnboardingFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3285BD95B564CA2A948E511 /* OnboardingFlowCoordinator.swift */; }; + 11D2FDD22DDF34F8323489B9 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C537DE821FED94D23467B6C4 /* PillUtilities.swift */; }; 1224084B7E289E0830BA2C54 /* VoiceMessageRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6A293D06BAB2B7A17D9314B /* VoiceMessageRoomTimelineView.swift */; }; 126CBCF5B0145FA1377C1316 /* Tracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83B574805B9812C111D6215D /* Tracing.swift */; }; 126EE01D8BEAEF26105D83C5 /* RoomDetailsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A5FEF17ED7E6176D922D4F /* RoomDetailsScreen.swift */; }; @@ -469,6 +470,7 @@ 5DB4334CBBA142376FF5FFEC /* preview_image.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 200626E8353AB2729444F991 /* preview_image.jpg */; }; 5DD0EF30070DC0A82C5CCD33 /* RoomMembersListManageMemberSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC853F9B4FBE039D2C16EC6B /* RoomMembersListManageMemberSheet.swift */; }; 5DD85A0FE3D85AEC3C7EFE36 /* DeveloperOptionsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C7CFA6B2A62A685FF6CE3 /* DeveloperOptionsScreenCoordinator.swift */; }; + 5DFC2A889D3B39DD47AC63A8 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C537DE821FED94D23467B6C4 /* PillUtilities.swift */; }; 5EC046E41755C095DAB1C3FF /* TimelineProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8C9BBB729C941BEE0E2A63 /* TimelineProviderProtocol.swift */; }; 5EDBDE802761B5ECB54E6787 /* LogLevel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2711E5996016ABD6EAAEB58A /* LogLevel.swift */; }; 5EE1D4E316D66943E97FDCF2 /* BloomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BEB970F500BFB248443FA1 /* BloomView.swift */; }; @@ -485,7 +487,6 @@ 6189B4ABD535CE526FA1107B /* StartChatViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DF438EAFC732D2D95D34BF6 /* StartChatViewModelTests.swift */; }; 61941DEE5F3834765770BE01 /* InviteUsersScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10F32E0B4B83D2A11EE8D011 /* InviteUsersScreenSelectedItem.swift */; }; 61A36B9BB2ADE36CEFF5E98C /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E93A1BE7D8A2EBCAD51EEB4 /* Array.swift */; }; - 62418EA4E3EB597AD184AEB6 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */; }; 62684AECDFC5C7DC989CBD9E /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 7B6BC3219ADD8AA0311D2B86 /* SnapshotTesting */; }; 627139A3D79F032BA81E3A53 /* UserSessionFlowCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA29BAE9B0F2D90E57B261C /* UserSessionFlowCoordinatorTests.swift */; }; 62910B515BCB4B455E24D7C1 /* AdvancedSettingsScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D086854995173E897F993C26 /* AdvancedSettingsScreenViewModelProtocol.swift */; }; @@ -586,6 +587,7 @@ 756EA0D663261889EF64E6D4 /* VoiceMessageRecordingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9CBF577B9711CFBB4FA40D /* VoiceMessageRecordingView.swift */; }; 7573D682F089205F7F1D96CF /* SessionDirectories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C2067FF58B4996323EB40C /* SessionDirectories.swift */; }; 75ED4B73983228BB6922CE3C /* KnockRequestsListScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A5C217DD0749EC709EED028 /* KnockRequestsListScreenViewModelProtocol.swift */; }; + 761EA50B2619307AB30891B8 /* PhishingDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB07F03461023BC39C730922 /* PhishingDetector.swift */; }; 762DAF94846C7AC8550F1CC1 /* MediaPlayerProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5E23D8EE6CBACF32F1EC874 /* MediaPlayerProviderProtocol.swift */; }; 762DB0973865293F0C3D3D7B /* SessionVerificationScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D452AF7B5F7E3A0A7DB54C /* SessionVerificationScreenViewModelProtocol.swift */; }; 763D69741D58D2B650BC1FC9 /* CallScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F37FA1A5D55633E1942B153B /* CallScreenCoordinator.swift */; }; @@ -699,7 +701,6 @@ 89198AE2649DD77673D5793B /* ExtensionLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41A8571A8A071FB41778C016 /* ExtensionLogger.swift */; }; 8944548A684F1C837CEC47F4 /* RoomMembersListScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D0946F77B696176E062D037 /* RoomMembersListScreenModels.swift */; }; 89658A44C9FC19B58FD1C226 /* ServerConfirmationScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08776C48FFB47CACF64ED10 /* ServerConfirmationScreenViewModelTests.swift */; }; - 899359A4D1147601F6C4E364 /* PillUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */; }; 899793EFC63DF93C3E0141E7 /* RoomMemberDetailsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FA60F848D1C14F873F9621A /* RoomMemberDetailsScreenCoordinator.swift */; }; 89B909AC66B96FA054EF3C14 /* InvitedRoomProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E95B3BDB80531C85CD50AE6 /* InvitedRoomProxy.swift */; }; 89DF67AECBF9D0EE0DDB7737 /* Tracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83B574805B9812C111D6215D /* Tracing.swift */; }; @@ -1156,6 +1157,7 @@ E9985DCD1B0D026D7E8BF809 /* ServerSelectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6640DB5B9171D163E6742639 /* ServerSelectionTests.swift */; }; E9D2ED1C4186931E3D5FDA4E /* QRCodeLoginScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 718D8767035D37E2DB5CC550 /* QRCodeLoginScreenViewModelProtocol.swift */; }; EA01A06EEDFEF4AE7652E5F3 /* NSRegularExpresion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BAC0F6C9644336E9567EE6 /* NSRegularExpresion.swift */; }; + EA2FECCD9E00D9784AC6017D /* PhishingDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB07F03461023BC39C730922 /* PhishingDetector.swift */; }; EA6613B29BA671F39CE1B1D2 /* ConfirmationDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = B383DCD3DCB19E00FD478A5F /* ConfirmationDialog.swift */; }; EA78A7512AFB1E5451744EB1 /* AppRouteURLParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E461B3C8BBBFCA400B268D14 /* AppRouteURLParserTests.swift */; }; EA8D941771E762A5D3D7FA0D /* FileMediaEventsTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430C73079A84654BF46A7FF5 /* FileMediaEventsTimelineView.swift */; }; @@ -1369,7 +1371,7 @@ 044E501B8331B339874D1B96 /* CompoundIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompoundIcon.swift; sourceTree = ""; }; 045253F9967A535EE5B16691 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; 046C0D3F53B0B5EF0A1F5BEA /* RoomSummaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryTests.swift; sourceTree = ""; }; - 048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 04BB8DDE245ED86C489BA983 /* AccessibilityIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifiers.swift; sourceTree = ""; }; 04DF593C3F7AF4B2FBAEB05D /* FileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManager.swift; sourceTree = ""; }; 0516C69708D5CBDE1A8E77EC /* RoomDirectorySearchProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchProxyProtocol.swift; sourceTree = ""; }; @@ -1439,7 +1441,7 @@ 128501375217576AF0FE3E92 /* RoomAttachmentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomAttachmentPicker.swift; sourceTree = ""; }; 12B09A94C519227264A41208 /* RoomMembershipDetailsProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembershipDetailsProxy.swift; sourceTree = ""; }; 12FD5280AF55AB7F50F8E47D /* preview_avatar_room.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = preview_avatar_room.jpg; sourceTree = ""; }; - 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = IntegrationTests.xctestplan; sourceTree = ""; }; + 1304D9191300873EADA52D6E /* IntegrationTests.xctestplan */ = {isa = PBXFileReference; path = IntegrationTests.xctestplan; sourceTree = ""; }; 130ED565A078F7E0B59D9D25 /* UNTextInputNotificationResponse+Creator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNTextInputNotificationResponse+Creator.swift"; sourceTree = ""; }; 136F80A613B55BDD071DCEA5 /* JoinRoomScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinRoomScreenModels.swift; sourceTree = ""; }; 13802897C7AFA360EA74C0B0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; @@ -1544,7 +1546,7 @@ 25F7FE40EF7490A7E09D7BE6 /* NotificationItemProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationItemProxy.swift; sourceTree = ""; }; 25F8664F1FB95AF3C4202478 /* PollFormScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollFormScreenCoordinator.swift; sourceTree = ""; }; 260004737C573A56FA01E86E /* Encodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encodable.swift; sourceTree = ""; }; - 267BB1D5B08A9511F894CB57 /* PreviewTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = PreviewTests.xctestplan; sourceTree = ""; }; + 267BB1D5B08A9511F894CB57 /* PreviewTests.xctestplan */ = {isa = PBXFileReference; path = PreviewTests.xctestplan; sourceTree = ""; }; 26B0A96B8FE4849227945067 /* VoiceMessageRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageRecorder.swift; sourceTree = ""; }; 26EAAB54C6CE91D64B69A9F8 /* AppLockServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockServiceProtocol.swift; sourceTree = ""; }; 2711E5996016ABD6EAAEB58A /* LogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogLevel.swift; sourceTree = ""; }; @@ -1617,7 +1619,7 @@ 3558A15CFB934F9229301527 /* RestorationToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestorationToken.swift; sourceTree = ""; }; 35AFCF4C05DEED04E3DB1A16 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; 35FA991289149D31F4286747 /* UserPreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPreference.swift; sourceTree = ""; }; - 36DA824791172B9821EACBED /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 36DA824791172B9821EACBED /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberProxyMock.swift; sourceTree = ""; }; 371B248460BD1A3F20318137 /* TimelineProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineProvider.swift; sourceTree = ""; }; 376D941BF8BB294389C0DE24 /* MapTilerURLBuildersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTilerURLBuildersTests.swift; sourceTree = ""; }; @@ -2027,7 +2029,7 @@ 8D55702474F279D910D2D162 /* RoomStateEventStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomStateEventStringBuilder.swift; sourceTree = ""; }; 8D8169443E5AC5FF71BFB3DB /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = ""; }; 8DA1E8F287680C8ED25EDBAC /* NetworkMonitorMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkMonitorMock.swift; sourceTree = ""; }; - 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UITests.xctestplan; sourceTree = ""; }; + 8E088F2A1B9EC529D3221931 /* UITests.xctestplan */ = {isa = PBXFileReference; path = UITests.xctestplan; sourceTree = ""; }; 8E1584F8BCF407BB94F48F04 /* EncryptionResetPasswordScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionResetPasswordScreen.swift; sourceTree = ""; }; 8EAF4A49F3ACD8BB8B0D2371 /* ClientSDKMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientSDKMock.swift; sourceTree = ""; }; 8F062DD2CCD95DC33528A16F /* KnockRequestProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnockRequestProxy.swift; sourceTree = ""; }; @@ -2158,6 +2160,7 @@ AACE9B8E1A4AE79A7E2914F6 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = es; path = es.lproj/Localizable.stringsdict; sourceTree = ""; }; AAD01F7FC2BBAC7351948595 /* UserProfile+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserProfile+Mock.swift"; sourceTree = ""; }; AAD8234D0E9C9B12BF9F240B /* LocationAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationAnnotation.swift; sourceTree = ""; }; + AB07F03461023BC39C730922 /* PhishingDetector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhishingDetector.swift; sourceTree = ""; }; AB26D5444A4A7E095222DE8B /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.stringsdict"; sourceTree = ""; }; ABA4CF2F5B4F68D02E412004 /* ServerConfirmationScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerConfirmationScreenViewModelProtocol.swift; sourceTree = ""; }; AC0275CEE9CA078B34028BDF /* AppLockScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockScreenViewModelTests.swift; sourceTree = ""; }; @@ -2222,7 +2225,7 @@ B53AC78E49A297AC1D72A7CF /* AppMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppMediator.swift; sourceTree = ""; }; B590BD4507D4F0A377FDE01A /* LoadableAvatarImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadableAvatarImage.swift; sourceTree = ""; }; B5D829FD8958376614504B18 /* TargetConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TargetConfiguration.swift; sourceTree = ""; }; - B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = ConfettiScene.scn; sourceTree = ""; }; + B61C339A2FDDBD067FF6635C /* ConfettiScene.scn */ = {isa = PBXFileReference; path = ConfettiScene.scn; sourceTree = ""; }; B63B69F9A2BC74DD40DC75C8 /* AdvancedSettingsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsScreenViewModel.swift; sourceTree = ""; }; B6404166CBF5CC88673FF9E2 /* RoomDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetails.swift; sourceTree = ""; }; B655A536341D2695158C6664 /* AuthenticationClientBuilderFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationClientBuilderFactory.swift; sourceTree = ""; }; @@ -2249,7 +2252,7 @@ BA40B98B098B6F0371B750B3 /* TemplateScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreenModels.swift; sourceTree = ""; }; BA919F521E9F0EE3638AFC85 /* BugReportScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BugReportScreen.swift; sourceTree = ""; }; BB284643AF7AB131E307DCE0 /* AudioSessionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioSessionProtocol.swift; sourceTree = ""; }; - BB576F4118C35E6B5124FA22 /* test_apple_image.heic */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_apple_image.heic; sourceTree = ""; }; + BB576F4118C35E6B5124FA22 /* test_apple_image.heic */ = {isa = PBXFileReference; path = test_apple_image.heic; sourceTree = ""; }; BB5B00A014307CE37B2812CD /* TimelineViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineViewModelProtocol.swift; sourceTree = ""; }; BB8BC4C791D0E88CFCF4E5DF /* ServerSelectionScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenCoordinator.swift; sourceTree = ""; }; BBEC57C204D77908E355EF42 /* AudioRecorderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecorderProtocol.swift; sourceTree = ""; }; @@ -2296,6 +2299,7 @@ C4756240773D26AB74C22668 /* OrientationManagerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrientationManagerProtocol.swift; sourceTree = ""; }; C4C89820BB2B88D4EA28131C /* BugReportScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BugReportScreenViewModelProtocol.swift; sourceTree = ""; }; C4CD503F5E0938FE53C7C6E7 /* UserDetailsEditScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailsEditScreenCoordinator.swift; sourceTree = ""; }; + C537DE821FED94D23467B6C4 /* PillUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillUtilities.swift; sourceTree = ""; }; C55679AF67545EF8087E47BE /* RoomMemberDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberDetails.swift; sourceTree = ""; }; C5599255A6C98EBDA77B76E6 /* ImageRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageRoomTimelineView.swift; sourceTree = ""; }; C55CC239AE12339C565F6C9A /* AudioRecorderStateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecorderStateTests.swift; sourceTree = ""; }; @@ -2331,7 +2335,6 @@ CA90BD288E5AE6BC643AFDDF /* TemplateScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreenCoordinator.swift; sourceTree = ""; }; CACA846B3E3E9A521D98B178 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; CAD9547E47C58930E2CE8306 /* CallScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallScreenViewModelTests.swift; sourceTree = ""; }; - CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillUtilities.swift; sourceTree = ""; }; CBBCC6E74774E79B599625D0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; CBF9AEA706926DD0DA2B954C /* JoinedRoomSize+MemberCount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JoinedRoomSize+MemberCount.swift"; sourceTree = ""; }; CC03209FDE8CE0810617BFFF /* RoomMembersListScreenMemberCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersListScreenMemberCell.swift; sourceTree = ""; }; @@ -2345,7 +2348,7 @@ CDB3227C7A74B734924942E9 /* RoomSummaryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryProvider.swift; sourceTree = ""; }; CDE3F3911FF7CC639BDE5844 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; CEE20623EB4A9B88FB29F2BA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/SAS.strings; sourceTree = ""; }; - CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = UnitTests.xctestplan; sourceTree = ""; }; + CEE41494C837AA403A06A5D9 /* UnitTests.xctestplan */ = {isa = PBXFileReference; path = UnitTests.xctestplan; sourceTree = ""; }; D01FD1171FF40E34D707FD00 /* BigIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BigIcon.swift; sourceTree = ""; }; D046ABB22E680F7C5054441B /* SecurityAndPrivacyScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityAndPrivacyScreenViewModelProtocol.swift; sourceTree = ""; }; D071F86CD47582B9196C9D16 /* UserDiscoverySection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDiscoverySection.swift; sourceTree = ""; }; @@ -2404,7 +2407,7 @@ DC0AEA686E425F86F6BA0404 /* UNNotification+Creator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UNNotification+Creator.swift"; sourceTree = ""; }; DC10CCC8D68B863E20660DBC /* MessageForwardingScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageForwardingScreenViewModelProtocol.swift; sourceTree = ""; }; DC528B3764E3CF7FCFEF40E7 /* PollInteractionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollInteractionHandler.swift; sourceTree = ""; }; - DCA2D836BD10303F37FAAEED /* test_voice_message.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_voice_message.m4a; sourceTree = ""; }; + DCA2D836BD10303F37FAAEED /* test_voice_message.m4a */ = {isa = PBXFileReference; path = test_voice_message.m4a; sourceTree = ""; }; DCAC01A97A43BE07B9E94E43 /* ShareExtensionModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareExtensionModels.swift; sourceTree = ""; }; DCDAB580109C09A6AA97AF7E /* PollFormScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollFormScreenTests.swift; sourceTree = ""; }; DCF239C619971FDE48132550 /* SecureBackupLogoutConfirmationScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupLogoutConfirmationScreenModels.swift; sourceTree = ""; }; @@ -2447,7 +2450,7 @@ E5272BC4A60B6AD7553BACA1 /* BlurHashDecode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = ""; }; E53BFB7E4F329621C844E8C3 /* AnalyticsPromptScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsPromptScreen.swift; sourceTree = ""; }; E55B5EA766E89FF1F87C3ACB /* RoomNotificationSettingsProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomNotificationSettingsProxyProtocol.swift; sourceTree = ""; }; - E5E7D4EE7CA295E5039FDA21 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = portrait_test_video.mp4; sourceTree = ""; }; + E5E7D4EE7CA295E5039FDA21 /* portrait_test_video.mp4 */ = {isa = PBXFileReference; path = portrait_test_video.mp4; sourceTree = ""; }; E5E94DCFEE803E5ABAE8ACCE /* KeychainControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainControllerProtocol.swift; sourceTree = ""; }; E5F2B6443D1ED8602F328539 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = ""; }; E5FDFAA04174CC99FB66391C /* EditRoomAddressScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditRoomAddressScreenViewModel.swift; sourceTree = ""; }; @@ -2489,7 +2492,7 @@ ED0CBEAB5F796BEFBAF7BB6A /* VideoRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRoomTimelineView.swift; sourceTree = ""; }; ED1D792EB82506A19A72C8DE /* RoomTimelineItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineItemProtocol.swift; sourceTree = ""; }; ED33988DA4FD4FC666800106 /* SessionVerificationScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionVerificationScreenViewModel.swift; sourceTree = ""; }; - ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = message.caf; sourceTree = ""; }; + ED482057AE39D5C6D9C5F3D8 /* message.caf */ = {isa = PBXFileReference; path = message.caf; sourceTree = ""; }; ED49073BB1C1FC649DAC2CCD /* LocationRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineView.swift; sourceTree = ""; }; ED60E4D2CD678E1EBF16F77A /* BlockedUsersScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedUsersScreen.swift; sourceTree = ""; }; EE378083653EF0C9B5E9D580 /* EmoteRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmoteRoomTimelineItemContent.swift; sourceTree = ""; }; @@ -3063,6 +3066,7 @@ isa = PBXGroup; children = ( 01C4C7DB37597D7D8379511A /* Assets.xcassets */, + D174C6E7DCA00AAFC0169925 /* ElementCall */, A0C06C0F6A8621B22BFAEB56 /* Localizations */, 8AEA6A91159FA0D3EAFCCB0D /* Sounds */, ); @@ -4734,6 +4738,7 @@ 72F37B5DA798C9AE436F2C2C /* AttributedStringBuilderProtocol.swift */, 1E508AB0EDEE017FF4F6F8D1 /* DTHTMLElement+AttributedStringBuilder.swift */, C024C151639C4E1B91FCC68B /* ElementXAttributeScope.swift */, + AB07F03461023BC39C730922 /* PhishingDetector.swift */, A436057DBEA1A23CA8CB1FD7 /* UIFont+AttributedStringBuilder.h */, E8CA187FE656EE5A3F6C7DE5 /* UIFont+AttributedStringBuilder.m */, ); @@ -4921,10 +4926,10 @@ 15748C254911E3654C93B0ED /* MentionBuilder.swift */, E1E0B4A34E69BD2132BEC521 /* MessageText.swift */, 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */, - CB8D34E94AB07128DB73D6C7 /* PillUtilities.swift */, 86376BEE425704AEE197CA54 /* PillContext.swift */, 9CF1EE0AA78470C674554262 /* PillTextAttachment.swift */, 913C8E13B8B602C7B6C0C4AE /* PillTextAttachmentData.swift */, + C537DE821FED94D23467B6C4 /* PillUtilities.swift */, 7773CBFDBD458E0B7E270507 /* PillView.swift */, 8AE78FA0011E07920AE83135 /* PlainMentionBuilder.swift */, ); @@ -5499,6 +5504,13 @@ path = ShareExtension; sourceTree = ""; }; + D174C6E7DCA00AAFC0169925 /* ElementCall */ = { + isa = PBXGroup; + children = ( + ); + path = ElementCall; + sourceTree = ""; + }; D382E465AF067C1BF888BF8E /* View */ = { isa = PBXGroup; children = ( @@ -6633,7 +6645,8 @@ 5D70FAE4D2BF4553AFFFFE41 /* NotificationItemProxy.swift in Sources */, B89990DD875B0B603D4D4332 /* NotificationItemProxyProtocol.swift in Sources */, B14BC354E56616B6B7D9A3D7 /* NotificationServiceExtension.swift in Sources */, - 62418EA4E3EB597AD184AEB6 /* PillUtilities.swift in Sources */, + 761EA50B2619307AB30891B8 /* PhishingDetector.swift in Sources */, + 5DFC2A889D3B39DD47AC63A8 /* PillUtilities.swift in Sources */, 55CDD3968D95D1A820B5491E /* PlaceholderAvatarImage.swift in Sources */, F12F6BED7B6D7EE4BEE55039 /* PlainMentionBuilder.swift in Sources */, 76C874243A8C440D6CF7B344 /* ProcessInfo.swift in Sources */, @@ -7288,14 +7301,15 @@ 847DE3A7EB9FCA2C429C6E85 /* PINTextField.swift in Sources */, 7501442D52A65F73DF79FFD4 /* PaginationIndicatorRoomTimelineItem.swift in Sources */, BC7CA1379D7C24F47B1B8B7E /* PaginationIndicatorRoomTimelineView.swift in Sources */, + EA2FECCD9E00D9784AC6017D /* PhishingDetector.swift in Sources */, 5FA1DCE55973862632961D7C /* PhotoLibraryManager.swift in Sources */, 2D38D39B1789B91AE69F477F /* PhotoLibraryManagerMock.swift in Sources */, 962A4F8AD6312804E2C6BB6E /* PhotoLibraryPicker.swift in Sources */, EE4E2C1922BBF5169E213555 /* PillAttachmentViewProvider.swift in Sources */, - 899359A4D1147601F6C4E364 /* PillUtilities.swift in Sources */, 767D366C40F1311CFA333763 /* PillContext.swift in Sources */, 7708976CEE6AFB5CFAEFBA68 /* PillTextAttachment.swift in Sources */, 8C050A8012E6078BEAEF5BC8 /* PillTextAttachmentData.swift in Sources */, + 11D2FDD22DDF34F8323489B9 /* PillUtilities.swift in Sources */, 7E2BB42805C59DB57E95610F /* PillView.swift in Sources */, 9CBB04365408F9D6F46BA3A7 /* PinnedEventsTimelineFlowCoordinator.swift in Sources */, 5D52925FEB1B780C65B0529F /* PinnedEventsTimelineScreen.swift in Sources */, @@ -7977,7 +7991,9 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_NSE"; + OTHER_SWIFT_FLAGS = ( + "-DIS_NSE", + ); PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; @@ -8026,7 +8042,9 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; + OTHER_SWIFT_FLAGS = ( + "-DIS_MAIN_APP", + ); PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -8052,7 +8070,9 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_MAIN_APP"; + OTHER_SWIFT_FLAGS = ( + "-DIS_MAIN_APP", + ); PILLS_UT_TYPE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER).pills"; PRODUCT_BUNDLE_IDENTIFIER = "$(BASE_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = "$(APP_NAME)"; @@ -8316,7 +8336,9 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = "$(MARKETING_VERSION)"; - OTHER_SWIFT_FLAGS = "-DIS_NSE"; + OTHER_SWIFT_FLAGS = ( + "-DIS_NSE", + ); PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.nse"; PRODUCT_DISPLAY_NAME = "$(APP_DISPLAY_NAME)"; PRODUCT_NAME = NSE; diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 605f28feb..e6f3fa43a 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -195,6 +195,19 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg ) } + func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool { + guard let confirmationParameters = url.confirmationParameters else { + return false + } + ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(), + title: L10n.dialogConfirmLinkTitle, + message: L10n.dialogConfirmLinkMessage(confirmationParameters.displayString, + confirmationParameters.internalURL.absoluteString), + primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), + secondaryButton: .init(title: L10n.actionContinue) { openURLAction(confirmationParameters.internalURL) }) + return true + } + func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool { // Parse into an AppRoute to redirect these in a type safe way. diff --git a/ElementX/Sources/Application/AppCoordinatorProtocol.swift b/ElementX/Sources/Application/AppCoordinatorProtocol.swift index 232f0ddb1..f17fcaac0 100644 --- a/ElementX/Sources/Application/AppCoordinatorProtocol.swift +++ b/ElementX/Sources/Application/AppCoordinatorProtocol.swift @@ -13,5 +13,7 @@ protocol AppCoordinatorProtocol: CoordinatorProtocol { @discardableResult func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool + func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool + func handleUserActivity(_ userActivity: NSUserActivity) } diff --git a/ElementX/Sources/Application/Application.swift b/ElementX/Sources/Application/Application.swift index 1dec87543..4ebf94f36 100644 --- a/ElementX/Sources/Application/Application.swift +++ b/ElementX/Sources/Application/Application.swift @@ -11,7 +11,6 @@ import SwiftUI struct Application: App { @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @Environment(\.openURL) private var openURL - @State private var alert: AlertInfo? private var appCoordinator: AppCoordinatorProtocol! @@ -36,20 +35,16 @@ struct Application: App { return .handled } - if let confirmationParameters = url.confirmationParameters { - alert = .init(id: .confirmURL, - title: "Test", - message: "Test", - primaryButton: .init(title: "Confirm") { openURL(confirmationParameters.internalURL) }, - secondaryButton: .init(title: L10n.actionCancel, action: nil)) - + if appCoordinator.handlePotentialPhishingAttempt(url: url, openURLAction: { url in + openURL(url, isExternalURL: false) + }) { return .handled } return .systemAction }) .onOpenURL { url in - openURL(url) + openURL(url, isExternalURL: true) } .onContinueUserActivity("INStartVideoCallIntent") { userActivity in // `INStartVideoCallIntent` is to be replaced with `INStartCallIntent` @@ -59,14 +54,13 @@ struct Application: App { .task { appCoordinator.start() } - .alert(item: $alert) } } // MARK: - Private - private func openURL(_ url: URL) { - if !appCoordinator.handleDeepLink(url, isExternalURL: true) { + private func openURL(_ url: URL, isExternalURL: Bool) { + if !appCoordinator.handleDeepLink(url, isExternalURL: isExternalURL) { openURLInSystemBrowser(url) } } @@ -97,7 +91,3 @@ struct Application: App { openURL(url) } } - -enum ApplicationAlertType { - case confirmURL -} diff --git a/ElementX/Sources/Other/Extensions/CharacterSet.swift b/ElementX/Sources/Other/Extensions/CharacterSet.swift index 6eacb1dc7..8b96dc66a 100644 --- a/ElementX/Sources/Other/Extensions/CharacterSet.swift +++ b/ElementX/Sources/Other/Extensions/CharacterSet.swift @@ -28,4 +28,5 @@ extension CharacterSet { }() static let matrixUserIDAllowedCharacters = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyz0123456789._=-/@:") + static let roomAliasAllowedCharacters = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyz0123456789!$&‘()*+/;=?@[]-._:#") } diff --git a/ElementX/Sources/Other/Extensions/String.swift b/ElementX/Sources/Other/Extensions/String.swift index 8be6cdfae..a6cd5ac7a 100644 --- a/ElementX/Sources/Other/Extensions/String.swift +++ b/ElementX/Sources/Other/Extensions/String.swift @@ -118,3 +118,22 @@ extension String { return UTType(filenameExtension: fileExtension) != nil ? fileExtension : "bin" } } + +extension String { + /// To be used if the string is actually a URL + var asSanitizedLink: String { + var link = self + if !link.contains("://") { + link.insert(contentsOf: "https://", at: link.startIndex) + } + + // Don't include punctuation characters at the end of links + // e.g `https://element.io/blog:` <- which is a valid link but the wrong place + while !link.isEmpty, + link.rangeOfCharacter(from: .punctuationCharacters, options: .backwards)?.upperBound == link.endIndex { + link = String(link.dropLast()) + } + + return link + } +} diff --git a/ElementX/Sources/Other/Extensions/URL.swift b/ElementX/Sources/Other/Extensions/URL.swift index 998c869fe..11925e8a9 100644 --- a/ElementX/Sources/Other/Extensions/URL.swift +++ b/ElementX/Sources/Other/Extensions/URL.swift @@ -126,23 +126,26 @@ extension URL: @retroactive ExpressibleByStringLiteral { } struct ConfirmURLParameters { + static let internalURLKey = "internalURL" + static let displayStringKey = "displayString" + let internalURL: URL - let linkString: String + let displayString: String var urlQueryItems: [URLQueryItem] { - [URLQueryItem(name: "internalURL", value: internalURL.absoluteString), - URLQueryItem(name: "linkString", value: linkString)] + [URLQueryItem(name: Self.internalURLKey, value: internalURL.absoluteString), + URLQueryItem(name: Self.displayStringKey, value: displayString)] } } extension ConfirmURLParameters { init?(queryItems: [URLQueryItem]) { - guard let internalURLString = queryItems.first(where: { $0.name == "internalURL" })?.value, + guard let internalURLString = queryItems.first(where: { $0.name == Self.internalURLKey })?.value, let internalURL = URL(string: internalURLString), - let externalURLString = queryItems.first(where: { $0.name == "linkString" })?.value else { + let externalURLString = queryItems.first(where: { $0.name == Self.displayStringKey })?.value else { return nil } - linkString = externalURLString + displayString = externalURLString self.internalURL = internalURL } } diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift index b2bf4cb04..e8ee4604a 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift @@ -178,7 +178,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol { return nil } - let link = sanitizeLink(String(string[matchRange])) + let link = String(string[matchRange]).asSanitizedLink return TextParsingMatch(type: .link(urlString: link), range: match.range) }) @@ -292,85 +292,32 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol { } } } - - private func sanitizeLink(_ string: String) -> String { - var link = string - if !link.contains("://") { - link.insert(contentsOf: "https://", at: link.startIndex) - } - - // Don't include punctuation characters at the end of links - // e.g `https://element.io/blog:` <- which is a valid link but the wrong place - while !link.isEmpty, - link.rangeOfCharacter(from: .punctuationCharacters, options: .backwards)?.upperBound == link.endIndex { - link = String(link.dropLast()) - } - - return link - } private func detectPhishingAttempts(_ attributedString: NSMutableAttributedString) { attributedString.enumerateAttribute(.link, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in guard value != nil, let internalURL = value as? URL else { return } - let linkString = attributedString.attributedSubstring(from: range).string - // Some phishing attempts can be hidden by using the unicode character "﹒" instead of "." - let correctedLinkString = attributedString.attributedSubstring(from: range).string.replacingOccurrences(of: "﹒", with: ".") + let displayString = attributedString.attributedSubstring(from: range).string - // We check if we the link string contains a matrix user ID. - if let match = MatrixEntityRegex.userIdentifierRegex.firstMatch(in: correctedLinkString), - let matchRange = Range(match.range, in: correctedLinkString) { - let identifier = String(correctedLinkString[matchRange]) - - // We also make sure that the link string is just the user ID - // We also trim any invalid character that might hide the phishing attempt - let trimmedLinkString = correctedLinkString.lowercased().trimmingCharacters(in: .matrixUserIDAllowedCharacters.inverted) - if identifier == trimmedLinkString, - isMatrixUserIDPhishingAttempt(internalURL: internalURL, identifier: identifier) { - handlePhishingAttempt(for: attributedString, in: range, internalURL: internalURL, linkString: linkString) - } - // Else we check if the link string is itself what is considered a tappable link for the OS - } else if MatrixEntityRegex.linkRegex.firstMatch(in: correctedLinkString) != nil { - // Then we compare the external URL with the internal one - // To avoid false positives like [Matrix.org](https://matrix.org) we sanitize and lowercase - let trimmedLinkString = sanitizeLink(correctedLinkString).lowercased().trimmingCharacters(in: .urlAllowedCharacters.inverted) - if sanitizeLink(correctedLinkString).lowercased() != sanitizeLink(internalURL.absoluteString).lowercased() { - handlePhishingAttempt(for: attributedString, in: range, internalURL: internalURL, linkString: linkString) - } - // Else we check if we the link string contains a matrix user ID. + guard PhishingDetector.isPhishingAttempt(displayString: displayString, internalURL: internalURL) else { + return } + handlePhishingAttempt(for: attributedString, in: range, internalURL: internalURL, displayString: displayString) } } - private func isMatrixUserIDPhishingAttempt(internalURL: URL, identifier: String) -> Bool { - // if is not a matrix entity then is a phishing attempt - guard let internalMatrixEntity = parseMatrixEntityFrom(uri: internalURL.absoluteString) else { - return true - } - - // If it is we check if is a user - switch internalMatrixEntity.id { - case .user(let id): - // If it is, and it does not match the external one, it's a phishing attempt - return id != identifier - default: - break - } - return true - } - private func handlePhishingAttempt(for attributedString: NSMutableAttributedString, in range: NSRange, internalURL: URL, - linkString: String) { + displayString: String) { // Let's remove the existing link attribute attributedString.removeAttribute(.link, range: range) var urlComponents = URLComponents() urlComponents.scheme = URL.confirmationScheme urlComponents.host = "" - let parameters = ConfirmURLParameters(internalURL: internalURL, linkString: linkString) + let parameters = ConfirmURLParameters(internalURL: internalURL, displayString: displayString) urlComponents.queryItems = parameters.urlQueryItems guard let finalURL = urlComponents.url else { diff --git a/ElementX/Sources/Other/HTMLParsing/PhishingDetector.swift b/ElementX/Sources/Other/HTMLParsing/PhishingDetector.swift new file mode 100644 index 000000000..003b88e6e --- /dev/null +++ b/ElementX/Sources/Other/HTMLParsing/PhishingDetector.swift @@ -0,0 +1,96 @@ +// +// Copyright 2025 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Foundation +import MatrixRustSDK + +enum PhishingDetector { + static func isPhishingAttempt(displayString: String, internalURL: URL) -> Bool { + // Some phishing attempts can be hidden by using the unicode character "﹒" instead of "." + let disambiguatedDisplayString = displayString.replacingOccurrences(of: "﹒", with: ".") + let linkMatch = MatrixEntityRegex.linkRegex.firstMatch(in: disambiguatedDisplayString) + let linkMatchLength = linkMatch?.range.length ?? 0 + + // We check if we the link string contains a matrix user ID. + if let match = MatrixEntityRegex.userIdentifierRegex.firstMatch(in: disambiguatedDisplayString), + // If there is a bigger permalink including it we leave it handled by the link branch + linkMatchLength <= match.range.length, + let matchRange = Range(match.range, in: disambiguatedDisplayString) { + let identifier = String(disambiguatedDisplayString[matchRange]) + + // We also make sure that the link string is just the user ID + // We also trim any invalid character that might hide the phishing attempt + // Like by using whitespaces emojis or other invalid symbols e.g click here [👉️ @alice:matrix.org](https://matrix.org) + let trimmedDisplayString = disambiguatedDisplayString.lowercased().trimmingCharacters(in: .matrixUserIDAllowedCharacters.inverted) + if identifier == trimmedDisplayString, + isMatrixUserIDPhishingAttempt(internalURL: internalURL, identifier: identifier) { + return true + } + // We check if we the link string contains a room alias. + } else if let match = MatrixEntityRegex.roomAliasRegex.firstMatch(in: disambiguatedDisplayString), + // If there is a bigger permalink including it we leave it handled by the link branch + linkMatchLength <= match.range.length, + let matchRange = Range(match.range, in: disambiguatedDisplayString) { + let alias = String(disambiguatedDisplayString[matchRange]) + + // We also make sure that the link string is just the user ID + // We also trim any invalid character that might hide the phishing attempt + // Like by using whitespaces emojis or other invalid symbols e.g click here [👉️ #room:matrix.org](https://matrix.org) + let trimmedDisplayString = disambiguatedDisplayString.lowercased().trimmingCharacters(in: .roomAliasAllowedCharacters.inverted) + if alias == trimmedDisplayString, + isRoomAliasPhishingAttempt(internalURL: internalURL, alias: alias) { + return true + } + // Else we check if the link string is itself what is considered a tappable link for the OS + } else if linkMatch != nil { + // Then we compare the external URL with the internal one + // To avoid false positives like [Matrix.org](https://matrix.org) we sanitize and lowercase + // And trim invalid characters that might hide phishing attemps + // Like emoji whitespaces and other invalid symbols e.g click here [👉️ https://element.io](https://matrix.org) + let trimmedDisplayString = disambiguatedDisplayString.asSanitizedLink.lowercased().trimmingCharacters(in: .urlAllowedCharacters.inverted) + if trimmedDisplayString != internalURL.absoluteString.asSanitizedLink.lowercased().removingPercentEncoding { + return true + } + } + + return false + } + + private static func isMatrixUserIDPhishingAttempt(internalURL: URL, identifier: String) -> Bool { + // if is not a matrix entity then is a phishing attempt + guard let internalMatrixEntity = parseMatrixEntityFrom(uri: internalURL.absoluteString) else { + return true + } + + // If it is we check if is a user + switch internalMatrixEntity.id { + case .user(let id): + // If it is, and it does not match the external one, it's a phishing attempt + return id != identifier + default: + break + } + return true + } + + private static func isRoomAliasPhishingAttempt(internalURL: URL, alias: String) -> Bool { + // if is not a matrix entity then is a phishing attempt + guard let internalMatrixEntity = parseMatrixEntityFrom(uri: internalURL.absoluteString) else { + return true + } + + // If it is we check if is a user + switch internalMatrixEntity.id { + case .roomAlias(let internalAlias): + // If it is, and it does not match the external one, it's a phishing attempt + return alias != internalAlias + default: + break + } + return true + } +} diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index bb0beb860..ac6836697 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -61,6 +61,10 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate navigationRootCoordinator.toPresentable() } + func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool { + fatalError("Not implemented.") + } + func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool { fatalError("Not implemented.") } diff --git a/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift b/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift index 0e053402f..c70e3165e 100644 --- a/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift +++ b/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift @@ -31,6 +31,10 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol { AnyView(ProgressView("Running Unit Tests")) } + func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool { + fatalError("Not implemented.") + } + func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool { fatalError("Not implemented.") } diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift index adc3e47cd..fa21f00bc 100644 --- a/UnitTests/Sources/AttributedStringBuilderTests.swift +++ b/UnitTests/Sources/AttributedStringBuilderTests.swift @@ -706,6 +706,305 @@ class AttributedStringBuilderTests: XCTestCase { XCTAssertEqual(foundAttachments, 2) } + // MARK: - Phishing prevention + + func testPhishingLink() { + let htmlString = "Hey check the following link https://element.io" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following link https://element.io") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "https://element.io") + } + + func testValidLink() { + let htmlString = "Hey check the following link" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://matrix.org") + } + + func testPhishingUserID() { + let htmlString = "Hey check the following user @alice:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following user @alice:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "@alice:matrix.org") + } + + func testValidUserIDLink() { + let htmlString = "Hey check the following user @alice:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + checkAttachment(attributedString: attributedString, expectedRuns: 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://matrix.to/#/@alice:matrix.org") + } + + func testPhishingUserIDWithAnotherUserIDPermalink() { + let htmlString = "Hey check the following user @alice:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following user @alice:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.to/#/@bob:matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "@alice:matrix.org") + } + + func testPhishingUserIDWithDistractingCharacters() { + let htmlString = "Hey check the following user 👉️ @alice:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following user 👉️ @alice:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "👉️ @alice:matrix.org") + } + + func testPhishingLinkWithDistractingCharacters() { + let htmlString = "Hey check the following link 👉️ https://element.io" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following link 👉️ https://element.io") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "👉️ https://element.io") + } + + func testValidLinkWithDistractingCharacters() { + let htmlString = "Hey check the following link 👉️ https://element.io" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + XCTAssertEqual(String(attributedString.characters), "Hey check the following link 👉️ https://element.io") + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://element.io") + } + + func testPhishingLinkWithFakeDotCharacter() { + let htmlString = "Hey check the following link https://element﹒io" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following link https://element﹒io") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "https://element﹒io") + } + + func testPhishingMatrixPermalinks() { + let htmlString = "Hey check the following room https://matrix.to/#/#beautiful-room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.to/#/%23offensive-room:matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "https://matrix.to/#/#beautiful-room:matrix.org") + } + + func testValidMatrixPermalinks() { + let htmlString = "Hey check the following room https://matrix.to/#/#beautiful-room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + checkAttachment(attributedString: attributedString, expectedRuns: 2) + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://matrix.to/#/%23beautiful-room:matrix.org") + } + + func testPhishingRoomAlias() { + let htmlString = "Hey check the following room #room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following room #room:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "#room:matrix.org") + } + + func testValidRoomAliasLink() { + let htmlString = "Hey check the following user #room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + checkAttachment(attributedString: attributedString, expectedRuns: 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertFalse(link.requiresConfirmation) + XCTAssertEqual(link.absoluteString, "https://matrix.to/#/%23room:matrix.org") + } + + func testPhishingRoomAliasWithAnotherRoomAliasPermalink() { + let htmlString = "Hey check the following room #room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following room #room:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.to/#/%23another-room:matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "#room:matrix.org") + } + + func testRoomAliasWithDistractingCharacters() { + let htmlString = "Hey check the following user 👉️ #room:matrix.org" + + guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else { + XCTFail("Could not build the attributed string") + return + } + + XCTAssertEqual(String(attributedString.characters), "Hey check the following user 👉️ #room:matrix.org") + + XCTAssertEqual(attributedString.runs.count, 2) + + guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else { + XCTFail("Couldn't find the link") + return + } + XCTAssertTrue(link.requiresConfirmation) + XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org") + XCTAssertEqual(link.confirmationParameters?.displayString, "👉️ #room:matrix.org") + } + // MARK: - Private private func checkLinkIn(attributedString: AttributedString?, expectedLink: String, expectedRuns: Int) {