From dd21d4b45c09f55131703fd1ffec47dd06f9aaba Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 26 Mar 2022 00:38:34 -0500 Subject: [PATCH] tags: don't allow tags to start with '(' or '['. Also don't allow the words 'and', 'or', and 'not'. Related to #4949. --- app/logical/tag_name_validator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/logical/tag_name_validator.rb b/app/logical/tag_name_validator.rb index 08c8a58f5..491737dce 100644 --- a/app/logical/tag_name_validator.rb +++ b/app/logical/tag_name_validator.rb @@ -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?