diff --git a/models/site.rb b/models/site.rb index 0964ff2e..90e420e8 100644 --- a/models/site.rb +++ b/models/site.rb @@ -1226,6 +1226,8 @@ class Site < Sequel::Model raise ArgumentError, 'invalid character for filename' if c < 32 end + # scrub question marks (I should probably just be erroring out for this) + clean_path.gsub!('?', '') clean_path end diff --git a/tests/site_file_tests.rb b/tests/site_file_tests.rb index bc18f4ee..1d81535b 100644 --- a/tests/site_file_tests.rb +++ b/tests/site_file_tests.rb @@ -408,6 +408,13 @@ describe 'site_files' do _(File.exists?(@site.files_path('te[s]t.jpg'))).must_equal true end + it 'scrubs question marks' do + uploaded_file = Rack::Test::UploadedFile.new('./tests/files/te[s]t.jpg', 'image/jpeg') + upload 'te?st.jpg' => uploaded_file + _(last_response.body).must_match /successfully uploaded/i + _(File.exists?(@site.files_path('test.jpg'))).must_equal true + end + it 'sets site changed to false if index is empty' do uploaded_file = Rack::Test::UploadedFile.new('./tests/files/blankindex/index.html', 'text/html') upload 'index.html' => uploaded_file