Skip to content

Commit

Permalink
Use base64.URLEncoding for []byte parameters in query (grpc-ecosystem…
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoll authored Feb 18, 2021
1 parent a8496b1 commit 62529fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func parseField(fieldDescriptor protoreflect.FieldDescriptor, value string) (pro
case protoreflect.StringKind:
return protoreflect.ValueOfString(value), nil
case protoreflect.BytesKind:
v, err := base64.StdEncoding.DecodeString(value)
v, err := base64.URLEncoding.DecodeString(value)
if err != nil {
return protoreflect.Value{}, err
}
Expand Down Expand Up @@ -314,7 +314,7 @@ func parseMessage(msgDescriptor protoreflect.MessageDescriptor, value string) (p
case "google.protobuf.StringValue":
msg = &wrapperspb.StringValue{Value: value}
case "google.protobuf.BytesValue":
v, err := base64.StdEncoding.DecodeString(value)
v, err := base64.URLEncoding.DecodeString(value)
if err != nil {
return protoreflect.Value{}, err
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestPopulateParameters(t *testing.T) {
"uint32_value": {"4"},
"bool_value": {"true"},
"string_value": {"str"},
"bytes_value": {"Ynl0ZXM="},
"bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"},
"repeated_value": {"a", "b", "c"},
"repeated_message": {"1", "2", "3"},
"enum_value": {"1"},
Expand All @@ -129,7 +129,7 @@ func TestPopulateParameters(t *testing.T) {
"wrapper_u_int32_value": {"4"},
"wrapper_bool_value": {"true"},
"wrapper_string_value": {"str"},
"wrapper_bytes_value": {"Ynl0ZXM="},
"wrapper_bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"},
"map_value[key]": {"value"},
"map_value[second]": {"bar"},
"map_value[third]": {"zzz"},
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestPopulateParameters(t *testing.T) {
Uint32Value: 4,
BoolValue: true,
StringValue: "str",
BytesValue: []byte("bytes"),
BytesValue: []byte("abc123!?$*&()'-=@~"),
RepeatedValue: []string{"a", "b", "c"},
RepeatedMessage: []*wrapperspb.UInt64Value{{Value: 1}, {Value: 2}, {Value: 3}},
EnumValue: examplepb.EnumValue_Y,
Expand All @@ -177,7 +177,7 @@ func TestPopulateParameters(t *testing.T) {
WrapperUInt32Value: &wrapperspb.UInt32Value{Value: 4},
WrapperBoolValue: &wrapperspb.BoolValue{Value: true},
WrapperStringValue: &wrapperspb.StringValue{Value: "str"},
WrapperBytesValue: &wrapperspb.BytesValue{Value: []byte("bytes")},
WrapperBytesValue: &wrapperspb.BytesValue{Value: []byte("abc123!?$*&()'-=@~")},
MapValue: map[string]string{
"key": "value",
"second": "bar",
Expand Down

0 comments on commit 62529fa

Please sign in to comment.