From 733d50b642969fe3d3cf65633d4d0f12ca881c68 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 23 Sep 2020 17:20:45 -0400 Subject: [PATCH] Strip U+FFFC from status bodies when posting Fixes #112 --- Tusker/Models/Draft.swift | 6 ++++++ Tusker/Screens/Compose/ComposeView.swift | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Tusker/Models/Draft.swift b/Tusker/Models/Draft.swift index 191a40c8..8bc73ce3 100644 --- a/Tusker/Models/Draft.swift +++ b/Tusker/Models/Draft.swift @@ -29,6 +29,12 @@ class Draft: Codable, ObservableObject { attachments.count > 0 } + var textForPosting: String { + // when using dictation, iOS sometimes leaves a U+FFFC OBJECT REPLACEMENT CHARACTER behind in the text, + // which we want to strip out before actually posting the status + text.replacingOccurrences(of: "\u{fffc}", with: "") + } + init(accountID: String) { self.id = UUID() self.lastModified = Date() diff --git a/Tusker/Screens/Compose/ComposeView.swift b/Tusker/Screens/Compose/ComposeView.swift index 48e7c677..7524dd53 100644 --- a/Tusker/Screens/Compose/ComposeView.swift +++ b/Tusker/Screens/Compose/ComposeView.swift @@ -197,7 +197,7 @@ struct ComposeView: View { self.isPosting = false case let .success(uploadedAttachments): - let request = Client.createStatus(text: draft.text, + let request = Client.createStatus(text: draft.textForPosting, contentType: Preferences.shared.statusContentType, inReplyTo: draft.inReplyToID, media: uploadedAttachments,