about summary refs log tree commit diff
path: root/spec/validators/status_length_validator_spec.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-03-30 14:46:03 +0200
committerGitHub <noreply@github.com>2022-03-30 14:46:03 +0200
commitbbc7afa2a24519ac238cbcd4e8aec310a002c40e (patch)
tree1fa3182233d71a2f6897f50d6b180d4c502b1fd1 /spec/validators/status_length_validator_spec.rb
parent5554ff2a1d6f451d63d03f4eb0a740d8c91455de (diff)
Fix being able to post URLs longer than 4096 characters (#17908)
Diffstat (limited to 'spec/validators/status_length_validator_spec.rb')
-rw-r--r--spec/validators/status_length_validator_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb
index bef3f29f5..db9c728a8 100644
--- a/spec/validators/status_length_validator_spec.rb
+++ b/spec/validators/status_length_validator_spec.rb
@@ -50,6 +50,13 @@ describe StatusLengthValidator do
       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"
       status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
@@ -57,5 +64,13 @@ describe StatusLengthValidator do
       subject.validate(status)
       expect(status.errors).to_not have_received(:add)
     end
+
+    it 'does count both parts of remote usernames for overly long domains' do
+      text   = "@alice@#{'b' * 500}.com"
+      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
   end
 end