tags: don't allow tags with unbalanced parentheses.

Don't allow tags to have unbalanced parentheses, except for a few
emoticon tags as special exceptions to the rule.
This commit is contained in:
evazion
2022-04-07 03:06:36 -05:00
parent 3e8e33e663
commit 5f1c296011
4 changed files with 42 additions and 0 deletions

View File

@@ -18,6 +18,10 @@ class TagNameValidator < ActiveModel::EachValidator
record.errors.add(attribute, "'#{value}' cannot be more than #{MAX_TAG_LENGTH} characters long")
end
if !value.in?(Tag::PERMITTED_UNBALANCED_TAGS) && !value.has_balanced_parens?
record.errors.add(attribute, "'#{value}' cannot have unbalanced parentheses")
end
case value
when /\A_*\z/
record.errors.add(attribute, "cannot be blank")