users: don't allow names ending with file extensions.
This is so in the future we can have URLs like https://danbooru.donmai.us/users/evazion without problems caused by names like https://danbooru.donmai.us/users/evazion.json
This commit is contained in:
@@ -24,6 +24,8 @@ class UserNameValidator < ActiveModel::EachValidator
|
||||
rec.errors.add(attr, "can't start with '#{name.first}'")
|
||||
elsif name =~ /[[:punct:]]\z/
|
||||
rec.errors.add(attr, "can't end with '#{name.last}'")
|
||||
elsif name =~ /\.(html|json|xml|atom|rss|txt|js|css|csv|png|jpg|jpeg|gif|png|mp4|webm|zip|pdf|exe|sitemap)\z/i
|
||||
rec.errors.add(attr, "can't end with a file extension")
|
||||
elsif name =~ /__/
|
||||
rec.errors.add(attr, "can't contain multiple underscores in a row")
|
||||
elsif forbidden_characters.present?
|
||||
|
||||
Reference in New Issue
Block a user