mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:01:18 +08:00
FIX: Be able to handle long file extensions (#12375)
* FIX: Be able to handle long file extensions Some applications have really long file extensions, but if we truncate them weird behavior ensues. This commit changes the file extension size from 10 characters to 255 characters instead. See: https://meta.discourse.org/t/182824 * Keep truncation at 10, but allow uppercase and dashes
This commit is contained in:
@ -9,7 +9,7 @@ RSpec.describe UploadCreator do
|
||||
describe '#create_for' do
|
||||
describe 'when upload is not an image' do
|
||||
before do
|
||||
SiteSetting.authorized_extensions = 'txt'
|
||||
SiteSetting.authorized_extensions = 'txt|long-FileExtension'
|
||||
end
|
||||
|
||||
let(:filename) { "utf-8.txt" }
|
||||
@ -38,6 +38,19 @@ RSpec.describe UploadCreator do
|
||||
expect(user2.user_uploads.count).to eq(1)
|
||||
expect(upload.user_uploads.count).to eq(2)
|
||||
end
|
||||
|
||||
let(:longextension) { "fake.long-FileExtension" }
|
||||
let(:file2) { file_from_fixtures(longextension) }
|
||||
|
||||
it 'should truncate long extension names' do
|
||||
expect do
|
||||
UploadCreator.new(file2, "fake.long-FileExtension").create_for(user.id)
|
||||
end.to change { Upload.count }.by(1)
|
||||
|
||||
upload = Upload.last
|
||||
|
||||
expect(upload.extension).to eq('long-FileE')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when image is not authorized' do
|
||||
|
Reference in New Issue
Block a user