Commit b5e5632e authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow '@' in tag values

This allows using an email address (as is) as part of a tag. The main
problem that could arise is when parsing tags from a shell script, but
(AFAIK) '@' is not a special character when used in values (happy to be
corrected if not true).

The patch also moves the re to be compiled at class init time, should
use less resources; in my tests it is fine to use a compiled re from
multiple threads.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
Reviewed-by: default avatarMichael Hanselmann <>
parent f7e41aa2
......@@ -210,9 +210,10 @@ class TaggableObject(ConfigObject):
__slots__ = ConfigObject.__slots__ + ["tags"]
VALID_TAG_RE = re.compile("^[\w.+*/:@-]+$")
def ValidateTag(tag):
def ValidateTag(cls, tag):
"""Check if a tag is valid.
If the tag is invalid, an errors.TagError will be raised. The
......@@ -226,7 +227,7 @@ class TaggableObject(ConfigObject):
if not tag:
raise errors.TagError("Tags cannot be empty")
if not re.match("^[\w.+*/:-]+$", tag):
if not cls.VALID_TAG_RE.match(tag):
raise errors.TagError("Tag contains invalid characters")
def GetTags(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment