Skip to content

Commit

Permalink
Merge pull request #145 from hyperledger-labs/f-144
Browse files Browse the repository at this point in the history
vault fails to validate keys containing string(utf8.MaxRune) #144
  • Loading branch information
adecaro committed Oct 1, 2021
2 parents 7cf9a0f + 51ab039 commit 1bd8acc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion platform/view/services/db/keys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ package keys

import (
"regexp"
"unicode/utf8"

"github.com/pkg/errors"
)

var (
nsRegexp = regexp.MustCompile("^[a-zA-Z0-9._-]{1,20}$")
keyRegexp = regexp.MustCompile("^[a-zA-Z0-9._\u0000=+/-]{1,200}$")
keyRegexp = regexp.MustCompile("^[a-zA-Z0-9._\u0000=" + string(utf8.MaxRune) + "+/-]{1,200}$")
)

const NamespaceSeparator = "\u0000"
Expand Down
4 changes: 3 additions & 1 deletion platform/view/services/db/keys/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
"testing"
"unicode/utf8"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/keys"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/keys"
)

const (
Expand Down Expand Up @@ -57,6 +58,7 @@ func TestValidateKey(t *testing.T) {
assert.NoError(t, err)
assert.NoError(t, keys.ValidateKey(key))
assert.EqualError(t, keys.ValidateKey("_key?"), "key '_key?' is invalid")
assert.NoError(t, keys.ValidateKey("\x00"+string(utf8.MaxRune)+"initialized"))
}

func TestValidateNamespace(t *testing.T) {
Expand Down

0 comments on commit 1bd8acc

Please sign in to comment.