mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
dont allow directories to end with .htm or .html. Breaks the dashboard UI, also breaks the cdn
This commit is contained in:
parent
9dbec11353
commit
88ad085ac8
2 changed files with 15 additions and 1 deletions
|
@ -81,7 +81,12 @@ class SiteFile < Sequel::Model
|
||||||
return false, "#{is_directory ? 'directory' : 'file'} already exists"
|
return false, "#{is_directory ? 'directory' : 'file'} already exists"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless is_directory
|
if is_directory
|
||||||
|
if new_path.match(/\.html?$/)
|
||||||
|
return false, 'directory name cannot end with .htm or .html'
|
||||||
|
end
|
||||||
|
|
||||||
|
else # a file
|
||||||
mime_type = Magic.guess_file_mime_type site.files_path(self.path)
|
mime_type = Magic.guess_file_mime_type site.files_path(self.path)
|
||||||
extname = File.extname new_path
|
extname = File.extname new_path
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,15 @@ describe 'site_files' do
|
||||||
# No purge cache is executed because the directory is empty
|
# No purge cache is executed because the directory is empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'fails for directory name ending in .htm or .html' do
|
||||||
|
@site.create_directory 'dirone'
|
||||||
|
dirone = @site.site_files_dataset.where(path: 'dirone').first
|
||||||
|
res = dirone.rename('dasharezone.html')
|
||||||
|
_(res).must_equal [false, 'directory name cannot end with .htm or .html']
|
||||||
|
res = dirone.rename('dasharezone.htm')
|
||||||
|
_(res).must_equal [false, 'directory name cannot end with .htm or .html']
|
||||||
|
end
|
||||||
|
|
||||||
it 'wont set an empty directory' do
|
it 'wont set an empty directory' do
|
||||||
@site.create_directory 'dirone'
|
@site.create_directory 'dirone'
|
||||||
_(@site.site_files.select {|sf| sf.path == 'dirone'}.length).must_equal 1
|
_(@site.site_files.select {|sf| sf.path == 'dirone'}.length).must_equal 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue