tags: don't allow tags to start with '(' or '['.

Also don't allow the words 'and', 'or', and 'not'.

Related to #4949.
This commit is contained in:
evazion
2022-03-26 00:38:34 -05:00
parent d9d3c1dfe4
commit dd21d4b45c

View File

@@ -25,7 +25,7 @@ class TagNameValidator < ActiveModel::EachValidator
record.errors.add(attribute, "'#{value}' cannot contain asterisks ('*')")
when /,/
record.errors.add(attribute, "'#{value}' cannot contain commas (',')")
when /\A[-~_`%){}\]\/]/
when /\A[-~_`%(){}\[\]\/]/
record.errors.add(attribute, "'#{value}' cannot begin with a '#{value[0]}'")
when /_\z/
record.errors.add(attribute, "'#{value}' cannot end with an underscore")
@@ -39,7 +39,7 @@ class TagNameValidator < ActiveModel::EachValidator
record.errors.add(attribute, "'#{value}' cannot begin with '#{$1}:'")
when /\A(#{Tag.categories.regexp}):(.+)\z/i
record.errors.add(attribute, "'#{value}' cannot begin with '#{$1}:'")
when "new", "search"
when "new", "search", "and", "or", "not"
record.errors.add(attribute, "'#{value}' is a reserved name and cannot be used")
when /\A(.+)_\(cosplay\)\z/i
# XXX don't allow aliases here?