diff --git a/pkg/policy/selector/parsing.go b/pkg/policy/selector/parsing.go index e6deab8..13be0a1 100644 --- a/pkg/policy/selector/parsing.go +++ b/pkg/policy/selector/parsing.go @@ -14,17 +14,16 @@ var ( indexRegex = regexp.MustCompile(`^-?\d+$`) sliceRegex = regexp.MustCompile(`^((\-?\d+:\-?\d*)|(\-?\d*:\-?\d+))$`) - // - Unicode letters - // - Unicode combining marks - // - Unicode digits - // - Unicode connector punctuation - // - $, _ - // - hyphen (-) - // \p{L} - any kind of letter from any language - // \p{Mn}\p{Mc} - combining marks and spacing combining marks - // \p{Nd} - decimal numbers - // \p{Pc} - connector punctuation (like underscore) - fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}-]*?$`) + // Field name requirements: + // - Must start with ASCII letter, Unicode letter, or underscore + // - Can contain: + // - ASCII letters (a-z, A-Z) + // - ASCII digits (0-9) + // - Unicode letters (\p{L}) + // - Dollar sign ($) + // - Underscore (_) + // - Hyphen (-) + fieldRegex = regexp.MustCompile(`^\.[a-zA-Z_\p{L}][a-zA-Z0-9$_\p{L}\-]*$`) ) func Parse(str string) (Selector, error) { diff --git a/pkg/policy/selector/parsing_test.go b/pkg/policy/selector/parsing_test.go index e58e9b2..6c8caf4 100644 --- a/pkg/policy/selector/parsing_test.go +++ b/pkg/policy/selector/parsing_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/ucan-wg/go-ucan/pkg/policy/limits" )