]> cat aescling's git repositories - mastodon.git/commitdiff
Only URLs extract with pre-escaped text (#9991)
authorHinaloe <hina@hinaloe.net>
Sat, 9 Feb 2019 02:39:38 +0000 (11:39 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 9 Feb 2019 02:39:38 +0000 (03:39 +0100)
* [test] add japanese hashtag testcase

* Only URLs extract with pre-escaped text

( https://github.com/tootsuite/mastodon/issues/9989 )

app/lib/formatter.rb
spec/lib/formatter_spec.rb

index 2e358716968a4ba43e691988389442fd7417194c..6603b8df178c9138b0ec0e6c8f6d83e67fa8171a 100644 (file)
@@ -210,7 +210,7 @@ class Formatter
 
     # Note: I couldn't obtain list_slug with @user/list-name format
     # for mention so this requires additional check
-    special = Extractor.extract_entities_with_indices(escaped, options).map do |extract|
+    special = Extractor.extract_urls_with_indices(escaped, options).map do |extract|
       # exactly one of :url, :hashtag, :screen_name, :cashtag keys is present
       key = (extract.keys & [:url, :hashtag, :screen_name, :cashtag]).first
 
index 9872d375679dc0759974e6dd3d8fe2f3cf5290da..8fb6695a9bf12c738847adf224ad18e5bba6dfb2 100644 (file)
@@ -194,6 +194,14 @@ RSpec.describe Formatter do
         is_expected.to include '/tags/hashtag" class="mention hashtag" rel="tag">#<span>hashtag</span></a>'
       end
     end
+
+    context 'given text containing a hashtag with Unicode chars' do
+      let(:text)  { '#hashtagタグ' }
+
+      it 'creates a hashtag link' do
+        is_expected.to include '/tags/hashtag%E3%82%BF%E3%82%B0" class="mention hashtag" rel="tag">#<span>hashtagタグ</span></a>'
+      end
+    end
   end
 
   describe '#format_spoiler' do