diff --git a/models/site.rb b/models/site.rb index e2713b0d..b835ed5c 100644 --- a/models/site.rb +++ b/models/site.rb @@ -17,6 +17,7 @@ class Site < Sequel::Model image/svg+xml application/vnd.ms-fontobject application/x-font-ttf + application/vnd.ms-opentype application/octet-stream text/csv text/tsv @@ -28,10 +29,11 @@ class Site < Sequel::Model text/xml application/xml audio/midi + text/cache-manifest } + VALID_EXTENSIONS = %w{ - html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff woff2 json - geojson csv tsv mf ico pdf asc key pgp xml mid midi manifest + html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff woff2 json geojson csv tsv mf ico pdf asc key pgp xml mid midi manifest otf } MINIMUM_PASSWORD_LENGTH = 5 @@ -464,9 +466,10 @@ class Site < Sequel::Model mime_type = Magic.guess_file_mime_type uploaded_file[:tempfile].path extname = File.extname uploaded_file[:filename] - if extname == '' - extname = uploaded_file[:filename] - end + # Possibly needed logic for .dotfiles + #if extname == '' + # extname = uploaded_file[:filename] + #end unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) && Site::VALID_EXTENSIONS.include?(extname.sub(/^./, '').downcase) diff --git a/tests/files/cache.manifest b/tests/files/cache.manifest new file mode 100644 index 00000000..69b55079 --- /dev/null +++ b/tests/files/cache.manifest @@ -0,0 +1,7 @@ +CACHE MANIFEST +NETWORK: +/test.html +CACHE: +/test.css +/test.js +/test.png diff --git a/tests/files/chunkfive.otf b/tests/files/chunkfive.otf new file mode 100644 index 00000000..c2ba1d96 Binary files /dev/null and b/tests/files/chunkfive.otf differ diff --git a/tests/site_file_tests.rb b/tests/site_file_tests.rb index 30ac82e2..154d963a 100644 --- a/tests/site_file_tests.rb +++ b/tests/site_file_tests.rb @@ -40,9 +40,13 @@ describe 'site_files' do end it 'works with manifest files' do - $debug = true - upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/.manifest', 'text/plain') - File.exists?(@site.files_path('.manifest')).must_equal true + upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/cache.manifest', 'text/cache-manifest') + File.exists?(@site.files_path('cache.manifest')).must_equal true + end + + it 'works with otf fonts' do + upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype') + File.exists?(@site.files_path('chunkfive.otf')).must_equal true end it 'succeeds with index.html file' do