Skip to content

Commit 2b8f1e7

Browse files
committed
A minor fix for testing valid utf-8 string
https://jira.hyperledger.org/browse/FAB-2008 Change-Id: I5a687f4b2ac564c6b2dcc8d69226a4523beb2c22 Signed-off-by: manish <[email protected]>
1 parent 1f77a54 commit 2b8f1e7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

core/chaincode/shim/chaincode.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,10 @@ func splitCompositeKey(compositeKey string) (string, []string, error) {
397397
}
398398

399399
func validateCompositeKeyAttribute(str string) error {
400+
if !utf8.ValidString(str) {
401+
return fmt.Errorf("Not a valid utf8 string: [%x]", str)
402+
}
400403
for index, runeValue := range str {
401-
if !utf8.ValidRune(runeValue) {
402-
return fmt.Errorf("Not a valid utf8 string. Contains rune [%d] starting at byte position [%d]",
403-
runeValue, index)
404-
}
405404
if runeValue == minUnicodeRuneValue || runeValue == maxUnicodeRuneValue {
406405
return fmt.Errorf(`Input contain unicode %#U starting at position [%d]. %#U and %#U are not allowed in the input attribute of a composite key`,
407406
runeValue, index, minUnicodeRuneValue, maxUnicodeRuneValue)

0 commit comments

Comments
 (0)