mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
permit uploading of empty files #85
This commit is contained in:
parent
762b3c7ba6
commit
d0d6cec34e
2 changed files with 6 additions and 1 deletions
|
@ -493,7 +493,7 @@ class Site < Sequel::Model
|
|||
# extname = uploaded_file[:filename]
|
||||
#end
|
||||
|
||||
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) &&
|
||||
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/ || mime_type =~ /inode\/x-empty/) &&
|
||||
Site::VALID_EXTENSIONS.include?(extname.sub(/^./, '').downcase)
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -48,6 +48,11 @@ describe 'site_files' do
|
|||
end
|
||||
|
||||
describe 'upload' do
|
||||
it 'works with empty files' do
|
||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/empty.js', 'text/javascript')
|
||||
File.exists?(@site.files_path('empty.js')).must_equal true
|
||||
end
|
||||
|
||||
it 'manages files with invalid UTF8' do
|
||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/invalidutf8.html', 'text/html')
|
||||
File.exists?(@site.files_path('invalidutf8.html')).must_equal true
|
||||
|
|
Loading…
Add table
Reference in a new issue