Skip to content

Commit cef1048

Browse files
hinaloehiyuki2578
authored andcommitted
Only URLs extract with pre-escaped text (mastodon#9991)
* [test] add japanese hashtag testcase * Only URLs extract with pre-escaped text ( mastodon#9989 )
1 parent d898904 commit cef1048

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/lib/formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def utf8_friendly_extractor(text, options = {})
215215

216216
# Note: I couldn't obtain list_slug with @user/list-name format
217217
# for mention so this requires additional check
218-
special = Extractor.extract_entities_with_indices(escaped, options).map do |extract|
218+
special = Extractor.extract_urls_with_indices(escaped, options).map do |extract|
219219
# exactly one of :url, :hashtag, :screen_name, :cashtag keys is present
220220
key = (extract.keys & [:url, :hashtag, :screen_name, :cashtag]).first
221221

spec/lib/formatter_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@
194194
is_expected.to include '/tags/hashtag" class="mention hashtag" rel="tag">#<span>hashtag</span></a>'
195195
end
196196
end
197+
198+
context 'given text containing a hashtag with Unicode chars' do
199+
let(:text) { '#hashtagタグ' }
200+
201+
it 'creates a hashtag link' do
202+
is_expected.to include '/tags/hashtag%E3%82%BF%E3%82%B0" class="mention hashtag" rel="tag">#<span>hashtagタグ</span></a>'
203+
end
204+
end
197205
end
198206

199207
describe '#format_spoiler' do

0 commit comments

Comments
 (0)