commit f6044a9eeae0564d5b14a764542fc6a2d12e83f8
parent 26bd50c948a5b2efb48e767fc529fd75a68d6a60
Author: kunigaku <kunigaku@gmail.com>
Date: Wed, 20 Dec 2023 23:25:27 +0900
Fix Issue #1820 Hashtags including U+5009 to U+500D are not correctly parsed
Closes: https://github.com/damus-io/damus/pull/1830
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/damus-c/cursor.h b/damus-c/cursor.h
@@ -485,11 +485,11 @@ static inline int parse_str(struct cursor *cur, const char *str) {
return 1;
}
-static inline int is_whitespace(char c) {
+static inline int is_whitespace(int c) {
return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
}
-static inline int is_underscore(char c) {
+static inline int is_underscore(int c) {
return c == '_';
}
diff --git a/damusTests/HashtagTests.swift b/damusTests/HashtagTests.swift
@@ -545,4 +545,15 @@ final class HashtagTests: XCTestCase {
XCTAssertEqual(parsed[2].asText, " is allowed in hashtags")
}
+ // Japanese: bai (倍) (U+500D) (allowed in hashtags)
+ func testHashtagWithBaiKanji() {
+ let parsed = parse_note_content(content: .content("pow! #10倍界王拳 is allowed in hashtags",nil)).blocks
+
+ XCTAssertNotNil(parsed)
+ XCTAssertEqual(parsed.count, 3)
+ XCTAssertEqual(parsed[0].asText, "pow! ")
+ XCTAssertEqual(parsed[1].asHashtag, "10倍界王拳")
+ XCTAssertEqual(parsed[2].asText, " is allowed in hashtags")
+ }
+
}