From f6044a9eeae0564d5b14a764542fc6a2d12e83f8 Mon Sep 17 00:00:00 2001 From: kunigaku Date: Wed, 20 Dec 2023 23:25:27 +0900 Subject: [PATCH] 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 Signed-off-by: William Casarin --- damus-c/cursor.h | 4 ++-- damusTests/HashtagTests.swift | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/damus-c/cursor.h b/damus-c/cursor.h index bb3cc30f..77e54144 100644 --- 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 index 5297340a..ce857614 100644 --- 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") + } + }