Browse Source

Fix /api/v1/tags/:id route constraints (#18854)

The constraint was applied prior to decoding, and rejected anything containing
the '%' character, which would be used for anything with non-ASCII unicode
characters.
closed-social-glitch-2
Claire 2 years ago
committed by GitHub
parent
commit
726931fe4a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions
  1. +1
    -0
      app/controllers/api/v1/tags_controller.rb
  2. +1
    -1
      config/routes.rb

+ 1
- 0
app/controllers/api/v1/tags_controller.rb View File

@ -24,6 +24,7 @@ class Api::V1::TagsController < Api::BaseController
private
def set_or_create_tag
return not_found unless /\A(#{Tag::HASHTAG_NAME_RE})\z/.match?(params[:id])
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
end
end

+ 1
- 1
config/routes.rb View File

@ -530,7 +530,7 @@ Rails.application.routes.draw do
resource :note, only: :create, controller: 'accounts/notes'
end
resources :tags, only: [:show], constraints: { id: /#{Tag::HASHTAG_NAME_RE}/ } do
resources :tags, only: [:show] do
member do
post :follow
post :unfollow

Loading…
Cancel
Save