mirror of
https://github.com/neocities/neocities.git
synced 2025-07-20 01:26:03 +02:00
add defined file and path length limits
This commit is contained in:
parent
1870286f2a
commit
a1cb3c6a11
3 changed files with 43 additions and 1 deletions
|
@ -5,10 +5,22 @@ require 'sanitize'
|
|||
class SiteFile < Sequel::Model
|
||||
CLASSIFIER_LIMIT = 1_000_000
|
||||
CLASSIFIER_WORD_LIMIT = 25
|
||||
FILE_PATH_CHARACTER_LIMIT = 300
|
||||
FILE_NAME_CHARACTER_LIMIT = 100
|
||||
unrestrict_primary_key
|
||||
plugin :update_primary_key
|
||||
many_to_one :site
|
||||
|
||||
def self.path_too_long?(filename)
|
||||
return true if filename.length > FILE_PATH_CHARACTER_LIMIT
|
||||
false
|
||||
end
|
||||
|
||||
def self.name_too_long?(filename)
|
||||
return true if filename.length > FILE_NAME_CHARACTER_LIMIT
|
||||
false
|
||||
end
|
||||
|
||||
def before_destroy
|
||||
if is_directory
|
||||
site.site_files_dataset.where(path: /^#{Regexp.quote path}\//, is_directory: true).all.each do |site_file|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue