Skip to content

Commit

Permalink
[]byte in query now uses base64.StdEncoding
Browse files Browse the repository at this point in the history
Changed default encoding of []bytes in URL Query params to use standard
padded base64 encoding to be consistent with representation in json
serialized objects.
  • Loading branch information
lucasvo authored and achew22 committed Mar 8, 2018
1 parent 07b39ba commit 463c5ed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Here's the recommended process of contribution.
4. Make sure that your change follows best practices in Go
* [Effective Go](https://golang.org/doc/effective_go.html)
* [Go Code Review Comments](https://golang.org/wiki/CodeReviewComments)
5. Make sure that `make test` passes. (use swagger-codegen 2.1.6, not newer versions)
5. Make sure that `make test` passes. (use swagger-codegen 2.2.2, not newer versions)
6. Sign [a Contributor License Agreement](https://cla.developers.google.com/clas)
7. Open a pull request in Github

Expand Down
2 changes: 1 addition & 1 deletion runtime/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Uint32(val string) (uint32, error) {
// Bytes converts the given string representation of a byte sequence into a slice of bytes
// A bytes sequence is encoded in URL-safe base64 without padding
func Bytes(val string) ([]byte, error) {
b, err := base64.RawURLEncoding.DecodeString(val)
b, err := base64.StdEncoding.DecodeString(val)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func populateField(f reflect.Value, value string, props *proto.Properties) error
f.Field(0).SetString(value)
return nil
case "BytesValue":
bytesVal, err := base64.RawURLEncoding.DecodeString(value)
bytesVal, err := base64.StdEncoding.DecodeString(value)
if err != nil {
return fmt.Errorf("bad BytesValue: %s", value)
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPopulateParameters(t *testing.T) {
"uint32_value": {"4"},
"bool_value": {"true"},
"string_value": {"str"},
"bytes_value": {"Ynl0ZXM"},
"bytes_value": {"Ynl0ZXM="},
"repeated_value": {"a", "b", "c"},
"enum_value": {"1"},
"repeated_enum": {"1", "2", "0"},
Expand All @@ -58,7 +58,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": {"Ynl0ZXM="},
"map_value[key]": {"value"},
"map_value[second]": {"bar"},
"map_value[third]": {"zzz"},
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestPopulateParameters(t *testing.T) {
"uint32Value": {"4"},
"boolValue": {"true"},
"stringValue": {"str"},
"bytesValue": {"Ynl0ZXM"},
"bytesValue": {"Ynl0ZXM="},
"repeatedValue": {"a", "b", "c"},
"enumValue": {"1"},
"repeatedEnum": {"1", "2", "0"},
Expand All @@ -151,7 +151,7 @@ func TestPopulateParameters(t *testing.T) {
"wrapperUInt32Value": {"4"},
"wrapperBoolValue": {"true"},
"wrapperStringValue": {"str"},
"wrapperBytesValue": {"Ynl0ZXM"},
"wrapperBytesValue": {"Ynl0ZXM="},
},
filter: utilities.NewDoubleArray(nil),
want: &proto3Message{
Expand Down

0 comments on commit 463c5ed

Please sign in to comment.