]> cat aescling's git repositories - mastodon.git/commitdiff
Fix /api/v1/tags/:id route constraints (#18854)
authorClaire <claire.github-309c@sitedethib.com>
Wed, 20 Jul 2022 15:06:52 +0000 (17:06 +0200)
committeraescling <aescling+gitlab@cat.family>
Mon, 5 Sep 2022 04:27:56 +0000 (00:27 -0400)
The constraint was applied prior to decoding, and rejected anything containing
the '%' character, which would be used for anything with non-ASCII unicode
characters.

app/controllers/api/v1/tags_controller.rb
config/routes.rb

index d45015ff5a090a1d2628c2be53b9db5ad2245dc8..9e5c53330a56eba9afc9cf6a1e6ff574c252e03d 100644 (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
index 3c467f24a3abea9d764dee4f52c8b8f0174d97fd..52ba0956a274d4f3c4eba718229285f0ba22f53c 100644 (file)
@@ -554,7 +554,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