Skip to content

Commit

Permalink
Prevent sourceURL greater than length 255
Browse files Browse the repository at this point in the history
  • Loading branch information
tiger5226 committed Jul 11, 2020
1 parent ff05549 commit 8023552
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion daemon/processing/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,12 @@ func setCollectionMetadata(claim *model.Claim, list pb.ClaimList) {

func setSourceMetadata(claim *model.Claim, s *pb.Source) {
if s.GetUrl() != "" {
claim.SourceURL.SetValid(s.GetUrl())
const maxSourceURLLength = 255
sourceURL := s.GetUrl()
if len(sourceURL) > maxSourceURLLength {
sourceURL = sourceURL[:252] + "..."
}
claim.SourceURL.SetValid(sourceURL)
}
if len(s.GetHash()) > 0 {
claim.SourceHash.SetValid(hex.EncodeToString(s.GetHash()))
Expand Down

0 comments on commit 8023552

Please sign in to comment.