mirror of
https://github.com/neocities/neocities.git
synced 2025-08-01 23:31:52 +02:00
fix when unicode is used for filename and dir
This commit is contained in:
parent
e9afe63695
commit
b54b2a4818
4 changed files with 18 additions and 1 deletions
|
@ -130,7 +130,8 @@ post '/site_files/upload' do
|
|||
end
|
||||
end
|
||||
|
||||
file[:filename] = "#{dir_name}/#{site.scrubbed_path file[:filename]}"
|
||||
file[:filename] = "#{dir_name.force_encoding('UTF-8')}/#{site.scrubbed_path file[:filename].force_encoding('UTF-8')}"
|
||||
|
||||
if current_site.file_size_too_large? file[:tempfile].size
|
||||
file_upload_response "#{Rack::Utils.escape_html file[:filename]} is too large, upload cancelled."
|
||||
end
|
||||
|
|
|
@ -423,6 +423,14 @@ describe 'api' do
|
|||
_(site_file_exists?('test.jpg')).must_equal true
|
||||
end
|
||||
|
||||
it 'works with unicode chars on filename and dir' do
|
||||
create_site
|
||||
basic_authorize @user, @pass
|
||||
post '/api/upload', '詩經/詩經.jpg' => Rack::Test::UploadedFile.new('./tests/files/詩經.jpg', 'image/jpeg')
|
||||
_(res[:result]).must_equal 'success'
|
||||
_(site_file_exists?('詩經/詩經.jpg')).must_equal true
|
||||
end
|
||||
|
||||
it 'succeeds with two files' do
|
||||
create_site
|
||||
basic_authorize @user, @pass
|
||||
|
|
BIN
tests/files/詩經.jpg
Normal file
BIN
tests/files/詩經.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
|
@ -443,6 +443,14 @@ describe 'site_files' do
|
|||
end
|
||||
end
|
||||
|
||||
it 'works with unicode chars on filename and dir' do
|
||||
upload(
|
||||
'dir' => '詩經',
|
||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/詩經.jpg', 'image/jpeg')
|
||||
)
|
||||
_(@site.site_files_dataset.where(path: '詩經/詩經.jpg').count).must_equal 1
|
||||
end
|
||||
|
||||
it 'does not register site changing until root index.html is changed' do
|
||||
upload(
|
||||
'dir' => 'derpie/derptest',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue