Skip to content

Commit

Permalink
entering fediverse username in main search redirects to follow page
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Jan 27, 2025
1 parent 4f3aa9e commit 59dc930
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ModelsController < ApplicationController
include ModelListable
include Permittable

before_action :redirect_search, only: [:index], if: -> { params.key?(:q) }
before_action :get_model, except: [:bulk_edit, :bulk_update, :index, :new, :create]
before_action :get_creators_and_collections, only: [:new, :edit, :bulk_edit]
before_action :set_returnable, only: [:bulk_edit, :edit, :new]
Expand Down Expand Up @@ -172,6 +173,10 @@ def destroy

private

def redirect_search
redirect_to new_follow_path(uri: params[:q]) if params[:q]&.match?(/(@|acct:)?(?<username>[a-z0-9\-_.]+)(?:@(?<domain>.*))/)

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on a
user-provided value
may run slow on strings with many repetitions of '-'.
end

def generate_available_tag_list
@available_tags = ActsAsTaggableOn::Tag.where(
id: ActsAsTaggableOn::Tagging.where(
Expand Down

0 comments on commit 59dc930

Please sign in to comment.