Skip to content

Commit 77d41b0

Browse files
committed
Remove invisible Unicode character from text parsing
Strips the U+034F (Combining Grapheme Joiner) character from note text and user descriptions before further processing. This helps prevent invisible or unwanted characters from affecting text rendering and formatting.
1 parent f69dc65 commit 77d41b0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Kimis/Backend/TextParser/Render/TextParser+Body.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extension TextParser {
1818
texts.append("\(cw)")
1919
}
2020
var content = note.text
21+
content = content.replacingOccurrences(of: "\u{034F}", with: "")
2122
while removeDuplicatedNewLines, content.contains("\n\n") {
2223
content = content.replacingOccurrences(of: "\n\n", with: "\n")
2324
}

Kimis/Backend/TextParser/Render/TextParser+User.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ extension TextParser {
111111
func compileUserDescriptionSimple(with profile: UserProfile) -> NSMutableAttributedString {
112112
var desc = profile.description
113113
.trimmingCharacters(in: .whitespacesAndNewlines)
114-
// while desc.contains("\n\n") {
115-
// desc = desc.replacingOccurrences(of: "\n\n", with: "\n")
116-
// }
114+
desc = desc.replacingOccurrences(of: "\u{034F}", with: "")
115+
while desc.contains("\n\n") {
116+
desc = desc.replacingOccurrences(of: "\n\n", with: "\n")
117+
}
117118
if desc.isEmpty { desc = "This user did not provide a self introduction." }
118119
let items: [NSMutableAttributedString] = [
119120
NSMutableAttributedString(string: "\(desc)"),
@@ -130,9 +131,10 @@ extension TextParser {
130131
// Description
131132
var desc = profile.description
132133
.trimmingCharacters(in: .whitespacesAndNewlines)
133-
// while desc.contains("\n\n") {
134-
// desc = desc.replacingOccurrences(of: "\n\n", with: "\n")
135-
// }
134+
desc = desc.replacingOccurrences(of: "\u{034F}", with: "")
135+
while desc.contains("\n\n") {
136+
desc = desc.replacingOccurrences(of: "\n\n", with: "\n")
137+
}
136138
if desc.isEmpty, profile.fields.isEmpty {
137139
desc = "This user did not provide a self introduction."
138140
}

0 commit comments

Comments
 (0)