Skip to content

Commit

Permalink
fix: pr reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanmo226 committed Dec 12, 2024
1 parent 26d58a4 commit a713de1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ final class EncryptedStorage: EncryptedStorageType {
case version15
case version16
case version17
case version18

var version: SchemaVersion {
switch self {
Expand Down Expand Up @@ -84,14 +85,16 @@ final class EncryptedStorage: EncryptedStorageType {
return SchemaVersion(appVersion: "1.2.3", dbSchemaVersion: 16)
case .version17:
return SchemaVersion(appVersion: "1.3.0", dbSchemaVersion: 17)
case .version18:
return SchemaVersion(appVersion: "1.3.0", dbSchemaVersion: 18)
}
}
}

private lazy var migrationLogger = Logger.nested(in: Self.self, with: .migration)
private lazy var logger = Logger.nested(Self.self)

private let currentSchema: EncryptedStorageSchema = .version17
private let currentSchema: EncryptedStorageSchema = .version18
private let supportedSchemas = EncryptedStorageSchema.allCases

private let storageEncryptionKey: Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import XCTest
class PasswordProtectedMsgTest: XCTestCase {

func testPasswordProtectedMessageCompliance() {
let disallowTerms = ["[Classification: Data Control: Internal Data Control]", "droid"]
let disallowTerms = ["[Classification: Data Control: Internal Data Control]", "droid", "forbidden data"]

let subjectsToTest: [String: Bool] = [
"[Classification: Data Control: Internal Data Control] Quarter results": false,
Expand All @@ -21,7 +21,8 @@ class PasswordProtectedMsgTest: XCTestCase {
"Internal Data Control - Finance monitoring": true,
"Android phone update": true,
"droid phone": false,
"DROiD phone": false
"DROiD phone": false,
"[forbidden data] year results": false,
]

for (subject, expectedValue) in subjectsToTest {
Expand Down
26 changes: 14 additions & 12 deletions FlowCryptCommon/Extensions/StringExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,25 @@ public extension String {
return true
}

// Normalize subject for case-insensitive comparison
let lowerCaseSubject = self.lowercased()
let lowerSubject = self.lowercased()

// Check if any disallow term exists as an exact match in the subject
for term in disallowTerms {
let lowerCaseTerm = term.lowercased()

// Check for exact matches (full-term match within the subject)
if lowerCaseSubject.contains(lowerCaseTerm),
lowerCaseSubject == lowerCaseTerm ||
lowerCaseSubject.hasPrefix(lowerCaseTerm + " ") ||
lowerCaseSubject.hasSuffix(" " + lowerCaseTerm) ||
lowerCaseSubject.contains(" " + lowerCaseTerm + " ") {
// Escape special regex characters
let escapedTerm = NSRegularExpression.escapedPattern(for: term)

// Create regex pattern to ensure term appears as a separate token
let pattern = #"(^|\W)\#(escapedTerm)(\W|$)"#

guard let regex = try? NSRegularExpression(pattern: pattern, options: [.caseInsensitive]) else {
continue
}

let range = NSRange(lowerSubject.startIndex..., in: lowerSubject)
if regex.firstMatch(in: lowerSubject, range: range) != nil {
// Found a disallowed term as a separate token
return false
}
}

return true // Allow if no matches are found
}
}
2 changes: 2 additions & 0 deletions FlowCryptUI/Nodes/CoreAlertNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class CoreAlertNode: ASDisplayNode {
for match in matches {
if let url = match.url, let range = Range(match.range, in: text) {
attributedString.addAttribute(.link, value: url, range: NSRange(range, in: text))
attributedString.addAttribute(.underlineColor, value: UIColor.clear, range: NSRange(range, in: text))
attributedString.addAttribute(.foregroundColor, value: UIColor.blue, range: NSRange(range, in: text))
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion FlowCryptUI/Nodes/CustomAlertNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public final class CustomAlertNode: CoreAlertNode, ASTextNodeDelegate {
child: separatorNode
)

let contentStack = ASStackLayoutSpec(
direction: .vertical,
spacing: 10,
justifyContent: .center,
alignItems: .center,
children: [titleLabel, messageLabel]
)
contentStack.style.flexGrow = 1.0

let buttonStack = ASStackLayoutSpec(
direction: .horizontal,
spacing: 0,
Expand All @@ -82,7 +91,7 @@ public final class CustomAlertNode: CoreAlertNode, ASTextNodeDelegate {
spacing: 10,
justifyContent: .center,
alignItems: .stretch,
children: [titleLabel, messageLabel, separatorInsetSpec, buttonStack]
children: [contentStack, separatorInsetSpec, buttonStack]
)

let contentLayout = ASInsetLayoutSpec(
Expand Down
3 changes: 1 addition & 2 deletions appium/tests/screenobjects/new-message.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ class NewMessageScreen extends BaseScreen {
};

checkCustomAlertMessage = async (content: string) => {
console.log(content);
const customAlertMessageLabel = await this.customAlertMessageLabel;
console.log(await customAlertMessageLabel.getText());
expect(await customAlertMessageLabel.getText()).toContain(content);
};
changeFromEmail = async (email: string) => {
await this.showRecipientInputIfNeeded();
Expand Down

0 comments on commit a713de1

Please sign in to comment.