about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-22 10:28:43 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-22 10:28:43 +0100
commitff42233aaeed91f8c14da150c7241d3d0b72841f (patch)
treed8b6e5807bb722fc92087bc6c52679ad92e8e2b2
parente0e7a09cfed2b311f055522eea45caac0838d87a (diff)
parentf343ed42ff1d288989f3a577362cc672e4cae437 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
-rw-r--r--Dockerfile1
-rw-r--r--app/controllers/api/v1/tags_controller.rb2
-rw-r--r--app/models/account/field.rb3
-rw-r--r--spec/controllers/api/v1/tags_controller_spec.rb4
-rw-r--r--spec/models/account/field_spec.rb10
5 files changed, 17 insertions, 3 deletions
diff --git a/Dockerfile b/Dockerfile
index 081981d46..69153c030 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -56,6 +56,7 @@ RUN apt-get update && \
     useradd -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
     apt-get -y --no-install-recommends install whois \
         wget \
+        procps \
         libssl1.1 \
         libpq5 \
         imagemagick \
diff --git a/app/controllers/api/v1/tags_controller.rb b/app/controllers/api/v1/tags_controller.rb
index 0966ee469..272362c31 100644
--- a/app/controllers/api/v1/tags_controller.rb
+++ b/app/controllers/api/v1/tags_controller.rb
@@ -12,7 +12,7 @@ class Api::V1::TagsController < Api::BaseController
   end
 
   def follow
-    TagFollow.first_or_create!(tag: @tag, account: current_account, rate_limit: true)
+    TagFollow.create_with(rate_limit: true).find_or_create_by!(tag: @tag, account: current_account)
     render json: @tag, serializer: REST::TagSerializer
   end
 
diff --git a/app/models/account/field.rb b/app/models/account/field.rb
index ffc8dce80..4db4cac30 100644
--- a/app/models/account/field.rb
+++ b/app/models/account/field.rb
@@ -46,7 +46,8 @@ class Account::Field < ActiveModelSerializers::Model
       parsed_url.user.nil? &&
       parsed_url.password.nil? &&
       parsed_url.host.present? &&
-      parsed_url.normalized_host == parsed_url.host
+      parsed_url.normalized_host == parsed_url.host &&
+      (parsed_url.path.empty? || parsed_url.path == parsed_url.normalized_path)
   rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError
     false
   end
diff --git a/spec/controllers/api/v1/tags_controller_spec.rb b/spec/controllers/api/v1/tags_controller_spec.rb
index ac42660df..216faad87 100644
--- a/spec/controllers/api/v1/tags_controller_spec.rb
+++ b/spec/controllers/api/v1/tags_controller_spec.rb
@@ -33,7 +33,11 @@ RSpec.describe Api::V1::TagsController, type: :controller do
   end
 
   describe 'POST #follow' do
+    let!(:unrelated_tag) { Fabricate(:tag) }
+
     before do
+      TagFollow.create!(account: user.account, tag: unrelated_tag)
+
       post :follow, params: { id: name }
     end
 
diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb
index b4beec048..0ac9769bc 100644
--- a/spec/models/account/field_spec.rb
+++ b/spec/models/account/field_spec.rb
@@ -67,7 +67,15 @@ RSpec.describe Account::Field, type: :model do
       end
 
       context 'for an IDN URL' do
-        let(:value) { 'http://twitter.com∕dougallj∕status∕1590357240443437057.ê.cc/twitter.html' }
+        let(:value) { 'https://twitter.com∕dougallj∕status∕1590357240443437057.ê.cc/twitter.html' }
+
+        it 'returns false' do
+          expect(subject.verifiable?).to be false
+        end
+      end
+
+      context 'for a URL with a non-normalized path' do
+        let(:value) { 'https://github.com/octocatxxxxxxxx/../mastodon' }
 
         it 'returns false' do
           expect(subject.verifiable?).to be false