From 15751c7362988dcfa686a4f0bbdf555a436d69bf Mon Sep 17 00:00:00 2001 From: Fabio Bozzo Date: Mon, 2 Dec 2024 18:30:41 +0100 Subject: [PATCH] regex to be more restrictive and consistent --- pkg/policy/selector/parsing.go | 3 +-- pkg/policy/selector/parsing_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/policy/selector/parsing.go b/pkg/policy/selector/parsing.go index 251d8f3..2e758af 100644 --- a/pkg/policy/selector/parsing.go +++ b/pkg/policy/selector/parsing.go @@ -22,8 +22,7 @@ var ( // \p{Mn}\p{Mc} - combining marks and spacing combining marks // \p{Nd} - decimal numbers // \p{Pc} - connector punctuation (like underscore) - // \p{Sm}\p{So} - math symbols and other symbols - fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\p{Sm}\p{So}-]*?$`) + fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}-]*?$`) ) func Parse(str string) (Selector, error) { diff --git a/pkg/policy/selector/parsing_test.go b/pkg/policy/selector/parsing_test.go index 01d0b88..b7ff22d 100644 --- a/pkg/policy/selector/parsing_test.go +++ b/pkg/policy/selector/parsing_test.go @@ -591,7 +591,7 @@ func TestParse(t *testing.T) { ".mixed_kebab-case", ".with$dollar", ".MIXED_Case_123", - ".unicode⌘", + ".unicodeø", } for _, field := range validFields {