Skip to content

Commit

Permalink
Fix: json UTF-8 validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Apr 3, 2022
1 parent 9693490 commit acdcdb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/metadata/models/jsonb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql/driver"
stdJSON "encoding/json"
"errors"
"unicode/utf8"
)

// JSONB -
Expand All @@ -14,7 +15,10 @@ func (j JSONB) Value() (driver.Value, error) {
if j.IsNull() {
return nil, nil
}
return string(j), nil
if utf8.Valid(j) {
return string(j), nil
}
return nil, nil
}

// Scan -
Expand Down

0 comments on commit acdcdb7

Please sign in to comment.