diff --git a/proto/protovalidate/buf/validate/validate.proto b/proto/protovalidate/buf/validate/validate.proto index 1153909d..3e76513e 100644 --- a/proto/protovalidate/buf/validate/validate.proto +++ b/proto/protovalidate/buf/validate/validate.proto @@ -3828,7 +3828,7 @@ message StringRules { message: "must be a valid HTTP header name" expression: "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" - "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" + "'^:?[0-9a-zA-Z!#$%&\\'*+.^_|~\\x60-]+$' :" "'^[^\\u0000\\u000A\\u000D]+$')" }, (predefined).cel = { diff --git a/tools/internal/gen/buf/validate/validate.pb.go b/tools/internal/gen/buf/validate/validate.pb.go index 63a735ff..d82d16fc 100644 --- a/tools/internal/gen/buf/validate/validate.pb.go +++ b/tools/internal/gen/buf/validate/validate.pb.go @@ -8609,7 +8609,7 @@ const file_buf_validate_validate_proto_rawDesc = "" + "\x1dstring.protobuf_dot_fqn_empty\x12Uvalue is empty, which is not a valid fully-qualified Protobuf name with a leading dot\x1a%!rules.protobuf_dot_fqn || this != ''H\x00R\x0eprotobufDotFqn\x12\xac\x05\n" + "\x10well_known_regex\x18\x18 \x01(\x0e2\x18.buf.validate.KnownRegexB\xe5\x04\xc2H\xe1\x04\n" + "\xea\x01\n" + - "#string.well_known_regex.header_name\x12 must be a valid HTTP header name\x1a\xa0\x01rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :'^[^\\u0000\\u000A\\u000D]+$')\n" + + "#string.well_known_regex.header_name\x12 must be a valid HTTP header name\x1a\xa0\x01rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?'^:?[0-9a-zA-Z!#$%&\\'*+.^_|~\\x60-]+$' :'^[^\\u0000\\u000A\\u000D]+$')\n" + "\x8d\x01\n" + ")string.well_known_regex.header_name_empty\x125value is empty, which is not a valid HTTP header name\x1a)rules.well_known_regex != 1 || this != ''\n" + "\xe1\x01\n" + diff --git a/tools/protovalidate-conformance/internal/cases/cases_strings.go b/tools/protovalidate-conformance/internal/cases/cases_strings.go index 0d75bb33..af6b8174 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_strings.go +++ b/tools/protovalidate-conformance/internal/cases/cases_strings.go @@ -1528,6 +1528,10 @@ func stringSuite() suites.Suite { Message: &cases.StringHttpHeaderName{Val: ":authority"}, Expected: results.Success(true), }, + "well_known_regex/header_name/strict/valid/all_chars": { + Message: &cases.StringHttpHeaderName{Val: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'*+-.^_|~`"}, + Expected: results.Success(true), + }, "well_known_regex/header_name/strict/valid/numbers": { Message: &cases.StringHttpHeaderName{Val: "abc-123"}, Expected: results.Success(true), @@ -1570,6 +1574,16 @@ func stringSuite() suites.Suite { }, ), }, + "well_known_regex/header_name/strict/invalid/comma": { + Message: &cases.StringHttpHeaderName{Val: "foo,bar"}, + Expected: results.Violations( + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + RuleId: proto.String("string.well_known_regex.header_name"), + }, + ), + }, "well_known_regex/header_name/strict/invalid/space": { Message: &cases.StringHttpHeaderName{Val: "foo bar"}, Expected: results.Violations(