Skip to content

Commit

Permalink
Merge pull request #43 from gertrude-app/replace-nullbytes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredh159 authored Sep 22, 2023
2 parents 01495b9 + e4c5bc8 commit f228faf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension CreateKeystrokeLines: Resolver {
KeystrokeLine(
userDeviceId: userDevice.id,
appName: input.appName,
line: input.line,
line: input.line.replacingOccurrences(of: "\0", with: "\u{FFFD}"),
filterSuspended: input.filterSuspended ?? false,
createdAt: input.time
)
Expand Down
19 changes: 19 additions & 0 deletions api/Tests/ApiTests/MacappPairResolvers/MacAppResolverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ final class MacAppResolverTests: ApiTestCase {
expect(inserted.createdAt).toEqual(.epoch)
}

func testInsertKeystrokeLineWithNullByte() async throws {
let user = try await Entities.user().withDevice()
let (uuid, _) = mockUUIDs()

let output = try await CreateKeystrokeLines.resolve(
with: [.init(
appName: "Xcode",
line: "Hello\0World", // <-- causes postgres to choke
filterSuspended: false,
time: .epoch
)],
in: context(user)
)

expect(output).toEqual(.success)
let inserted = try await Current.db.find(KeystrokeLine.Id(uuid))
expect(inserted.line).toEqual("Hello�World")
}

func testCreateUnlockRequests_v2() async throws {
let user = try await Entities.user().withDevice()
let blocked = CreateUnlockRequests_v2.Input.BlockedRequest(
Expand Down

0 comments on commit f228faf

Please sign in to comment.