Skip to content

Commit 28bc307

Browse files
committed
Escape NULL terminator in strings with correct glyph
1 parent 70cfbfc commit 28bc307

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Sources/Task.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension String {
5454
in: self,
5555
range: NSRange(location: 0, length: self.utf16.count),
5656
withTemplate: "\\\\$0"
57-
)
57+
).replacingOccurrences(of: "\0", with: "")
5858
}
5959
}
6060

Tests/ReactiveTaskTests/StringExtensionSpec.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class StringExtensionSpec: QuickSpec {
1010
expect("d\te\tf".escapingWhitespaces).to(equal("d\\\te\\\tf"))
1111
}
1212

13+
it("should escape the NULL terminator with the 'symbol for null' glyph (U+2400)") {
14+
expect("abc\0".escapingWhitespaces).to(equal("abc␀"))
15+
}
16+
1317
it("should not change the original string if it does not contain whitespaces") {
1418
expect("ReactiveTask").to(equal("ReactiveTask"))
1519
}

0 commit comments

Comments
 (0)