0
0
Fork 0

Fix being able to post URLs longer than 4096 characters (#17908)

This commit is contained in:
Eugen Rochko 2022-03-30 14:46:03 +02:00 committed by GitHub
parent 5554ff2a1d
commit bbc7afa2a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 14 deletions

View file

@ -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