File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ var MetadataPatternKey = regexp.MustCompile(
6565// MetadataPatternValue representing the metadata pattern for value.
6666var MetadataPatternValue = regexp .MustCompile ("^$|^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9+._-]*[a-zA-Z0-9]$" )
6767
68+ // Base64MedatadaPatternValue representing the metadata pattern for value when the value is expected to be a base64 encoded string.
69+ var Base64MedatadaPatternValue = regexp .MustCompile ("^[A-Za-z0-9+/]*={0,2}$" )
70+
6871// Metadata struct representing the JSON metadata.
6972type Metadata struct {
7073 Key string `json:"key"`
@@ -139,7 +142,10 @@ func validateKeyValue(meta []Metadata) error {
139142 if len (rmetadata .Value ) > MetadataValueMaxLength {
140143 return errors .Errorfc (codes .InvalidArgument , "Invalid length of metadata value" )
141144 }
142- if ! MetadataPatternValue .MatchString (rmetadata .Value ) {
145+
146+ // check if string matches MetadataPatternValue or a base64 encoded string that matches Base64MedatadaPatternValue,
147+ // as some of the metadata values can be base64 encoded, we want to allow those as well.
148+ if ! (MetadataPatternValue .MatchString (rmetadata .Value ) || Base64MedatadaPatternValue .MatchString (rmetadata .Value )) {
143149 return errors .Errorfc (codes .InvalidArgument , "Invalid metadata value" )
144150 }
145151 }
You can’t perform that action at this time.
0 commit comments