Fix `tagged` param not being normalized before querying tags (#10249)
parent
d4ef90eae3
commit
06663fcf87
|
@ -80,7 +80,13 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def hashtag_scope
|
def hashtag_scope
|
||||||
Status.tagged_with(Tag.find_by(name: params[:tag].downcase)&.id)
|
tag = Tag.find_normalized(params[:tag])
|
||||||
|
|
||||||
|
if tag
|
||||||
|
Status.tagged_with(tag.id)
|
||||||
|
else
|
||||||
|
Status.none
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|
|
@ -69,7 +69,13 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def hashtag_scope
|
def hashtag_scope
|
||||||
Status.tagged_with(Tag.find_by(name: params[:tagged])&.id)
|
tag = Tag.find_normalized(params[:tagged])
|
||||||
|
|
||||||
|
if tag
|
||||||
|
Status.tagged_with(tag.id)
|
||||||
|
else
|
||||||
|
Status.none
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_tag
|
def load_tag
|
||||||
@tag = Tag.find_by(name: params[:id].downcase)
|
@tag = Tag.find_normalized(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TagsController < ApplicationController
|
||||||
before_action :set_instance_presenter
|
before_action :set_instance_presenter
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@tag = Tag.find_by!(name: params[:id].downcase)
|
@tag = Tag.find_normalized!(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
|
|
|
@ -72,6 +72,14 @@ class Tag < ApplicationRecord
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_normalized(name)
|
||||||
|
find_by(name: name.mb_chars.downcase.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_normalized!(name)
|
||||||
|
find_normalized(name) || raise(ActiveRecord::RecordNotFound)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue