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