Skip to content
Snippets Groups Projects
Unverified Commit f28a12a5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add strict validation to snippet file names

parent 9a3ae331
No related branches found
No related tags found
No related merge requests found
Loading
@@ -29,7 +29,9 @@ class Snippet < ActiveRecord::Base
Loading
@@ -29,7 +29,9 @@ class Snippet < ActiveRecord::Base
   
validates :author, presence: true validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 } validates :title, presence: true, length: { within: 0..255 }
validates :file_name, presence: true, length: { within: 0..255 } validates :file_name, presence: true, length: { within: 0..255 },
format: { with: Gitlab::Regex.path_regex,
message: Gitlab::Regex.path_regex_message }
validates :content, presence: true validates :content, presence: true
validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values } validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values }
   
Loading
@@ -72,7 +74,7 @@ class Snippet < ActiveRecord::Base
Loading
@@ -72,7 +74,7 @@ class Snippet < ActiveRecord::Base
   
def visibility_level_field def visibility_level_field
visibility_level visibility_level
end end
   
class << self class << self
def search(query) def search(query)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment