about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/lib/activitypub/activity/create.rb2
-rw-r--r--app/models/tag.rb4
-rw-r--r--app/services/process_hashtags_service.rb2
-rw-r--r--config/routes.rb8
4 files changed, 8 insertions, 8 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index a0cf03686..263dbbb87 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -179,7 +179,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
   def process_hashtag(tag)
     return if tag['name'].blank?
 
-    hashtag = tag['name'].gsub(/\A#/, '').mb_chars.downcase
+    hashtag = tag['name'].gsub(/\A#/, '').gsub(':', '.').mb_chars.downcase
 
     return if !@options[:imported] && hashtag.starts_with?('self.', '_self.', 'local.', '_local.')
 
diff --git a/app/models/tag.rb b/app/models/tag.rb
index a6a1445a3..d3511a54e 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -19,7 +19,7 @@ class Tag < ApplicationRecord
   has_many :featured_tags, dependent: :destroy, inverse_of: :tag
   has_one :account_tag_stat, dependent: :destroy
 
-  HASHTAG_NAME_RE = '[[:word:]._\-]*[[:alpha:]._·\-][[:word:]._\-]*'
+  HASHTAG_NAME_RE = '[[:word:]:._\-]*[[:alpha:]:._·\-][[:word:]:._\-]*'
   HASHTAG_RE = /(?:^|[^\/\)\w])#(#{HASHTAG_NAME_RE})/i
 
   validates :name, presence: true, uniqueness: true, format: { with: /\A#{HASHTAG_NAME_RE}\z/i }
@@ -82,7 +82,7 @@ class Tag < ApplicationRecord
     end
 
     def find_normalized(name)
-      find_by(name: name.mb_chars.gsub(':', '.').downcase.to_s)
+      find_by(name: name.gsub(':', '.').mb_chars.downcase.to_s)
     end
 
     def find_normalized!(name)
diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb
index e8c2c95bb..07806b4a7 100644
--- a/app/services/process_hashtags_service.rb
+++ b/app/services/process_hashtags_service.rb
@@ -8,7 +8,7 @@ class ProcessHashtagsService < BaseService
     records = []
 
     tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
-      name = name.gsub(/\.\.+/, '.')
+      name = name.gsub(/[:.]+/, '.')
       next if name.blank?
       component_indices = name.size.times.select {|i| name[i] == '.'}
       component_indices << name.size - 1
diff --git a/config/routes.rb b/config/routes.rb
index c20fbf8ea..691baa4dd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -78,7 +78,7 @@ Rails.application.routes.draw do
   get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
   get '/@:username/media', to: 'accounts#show', as: :short_account_media
   get '/@:username/reblogs', to: 'accounts#show', as: :short_account_reblogs
-  get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag, constraints: { tag: /[\w._·\-]+/ }
+  get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag, constraints: { tag: /[\w:._·\-]+/ }
   get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
   get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
 
@@ -86,7 +86,7 @@ Rails.application.routes.draw do
   post '/interact/:id', to: 'remote_interaction#create'
 
   get '/explore', to: 'directories#index', as: :explore
-  get '/explore/:id', to: 'directories#show', as: :explore_hashtag, constraints: { id: /[\w._·\-]+/ }
+  get '/explore/:id', to: 'directories#show', as: :explore_hashtag, constraints: { id: /[\w:._·\-]+/ }
 
   namespace :settings do
     resource :profile, only: [:show, :update]
@@ -124,7 +124,7 @@ Rails.application.routes.draw do
     resource :migration, only: [:show, :update]
 
     resources :sessions, only: [:destroy]
-    resources :featured_tags, only: [:index, :create, :destroy], constraints: { id: /[\w._·\-]+/ }
+    resources :featured_tags, only: [:index, :create, :destroy], constraints: { id: /[\w:._·\-]+/ }
   end
 
   resources :media, only: [:show] do
@@ -293,7 +293,7 @@ Rails.application.routes.draw do
         resource :direct, only: :show, controller: :direct
         resource :home, only: :show, controller: :home
         resource :public, only: :show, controller: :public
-        resources :tag, only: :show, constraints: { id: /[\w._·\-]+/ }
+        resources :tag, only: :show, constraints: { id: /[\w:._·\-]+/ }
         resources :list, only: :show
       end