tags: don't allow tags to begin with a '/'.
Disallow tags from starting with a '/' character. This is so that tag
abbreviations in autocomplete, which start with a '/', don't conflict
with regular tags.
Also disallow some other punctuation characters: `%{})]. Currently no
tags start with these characters. This is to reserve other special
characters in case we need them for other future syntax extensions.
This commit is contained in:
@@ -7,12 +7,8 @@ class TagNameValidator < ActiveModel::EachValidator
|
||||
record.errors.add(attribute, "'#{value}' cannot contain asterisks ('*')")
|
||||
when /,/
|
||||
record.errors.add(attribute, "'#{value}' cannot contain commas (',')")
|
||||
when /\A~/
|
||||
record.errors.add(attribute, "'#{value}' cannot begin with a tilde ('~')")
|
||||
when /\A-/
|
||||
record.errors.add(attribute, "'#{value}' cannot begin with a dash ('-')")
|
||||
when /\A_/
|
||||
record.errors.add(attribute, "'#{value}' cannot begin with an underscore")
|
||||
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")
|
||||
when /__/
|
||||
|
||||
Reference in New Issue
Block a user