From: Claire Date: Wed, 30 Mar 2022 13:02:56 +0000 (+0200) Subject: Merge branch 'main' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=fc5dd0c538a8cf33d007a01e168b3bfc0cdc9060;p=mastodon.git Merge branch 'main' into glitch-soc/merge-upstream --- fc5dd0c538a8cf33d007a01e168b3bfc0cdc9060 diff --cc .github/workflows/build-image.yml index b3a8d5105,75c7b54a6..880fdfac9 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@@ -39,8 -35,8 +36,8 @@@ jobs - uses: docker/build-push-action@v2 with: context: . - platforms: ${{ matrix.os }} + platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - cache-from: type=registry,ref=tootsuite/mastodon:latest + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/mastodon:latest cache-to: type=inline diff --cc app/validators/status_length_validator.rb index 2a3ac8862,e107912b7..f93450ba6 --- a/app/validators/status_length_validator.rb +++ b/app/validators/status_length_validator.rb @@@ -1,9 -1,9 +1,9 @@@ # frozen_string_literal: true class StatusLengthValidator < ActiveModel::Validator - MAX_CHARS = 500 + MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i URL_PLACEHOLDER_CHARS = 23 - URL_PLACEHOLDER = "\1#{'x' * URL_PLACEHOLDER_CHARS}" + URL_PLACEHOLDER = 'x' * 23 def validate(status) return unless status.local? && !status.reblog? diff --cc spec/validators/status_length_validator_spec.rb index 643ea6d22,db9c728a8..4c80a59e6 --- a/spec/validators/status_length_validator_spec.rb +++ b/spec/validators/status_length_validator_spec.rb @@@ -55,10 -50,15 +55,17 @@@ describe StatusLengthValidator d expect(status.errors).to have_received(:add) end + it 'does not count overly long URLs as 23 characters flat' do + text = "http://example.com/valid?#{'#foo?' * 1000}" + status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false) + subject.validate(status) + expect(status.errors).to have_received(:add) + end + it 'counts only the front part of remote usernames' do - text = ('a' * 475) + " @alice@#{'b' * 30}.com" + username = '@alice' + chars = StatusLengthValidator::MAX_CHARS - 1 - username.length + text = ('a' * 475) + " #{username}@#{'b' * 30}.com" status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false) subject.validate(status)