Skip to content

Commit

Permalink
Merge pull request glitch-soc#1966 from ClearlyClaire/glitch-soc/merg…
Browse files Browse the repository at this point in the history
…e-upstream

Merge upstream changes
  • Loading branch information
ClearlyClaire authored Nov 22, 2022
2 parents e0e7a09 + ff42233 commit bdc61d4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def show
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

Expand Down
3 changes: 2 additions & 1 deletion app/models/account/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def verifiable?
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
Expand Down
4 changes: 4 additions & 0 deletions spec/controllers/api/v1/tags_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
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

Expand Down
10 changes: 9 additions & 1 deletion spec/models/account/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@
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
Expand Down

0 comments on commit bdc61d4

Please sign in to comment.