Skip to content

Commit

Permalink
privacy: Do not modify User.Ext or Regs.Ext if json.Marshal reports a…
Browse files Browse the repository at this point in the history
…n error.
  • Loading branch information
djcsdy committed May 27, 2020
1 parent 255fc04 commit 27e2e11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions privacy/ccpa/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ func (p Policy) Write(req *openrtb.BidRequest) error {
req.Regs = &openrtb.Regs{}
}

var err error

if req.Regs.Ext == nil {
req.Regs.Ext, err = json.Marshal(openrtb_ext.ExtRegs{USPrivacy: p.Value})
ext, err := json.Marshal(openrtb_ext.ExtRegs{USPrivacy: p.Value})
if err == nil {
req.Regs.Ext = ext
}
return err
}

Expand Down
7 changes: 4 additions & 3 deletions privacy/gdpr/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ func (p Policy) Write(req *openrtb.BidRequest) error {
req.User = &openrtb.User{}
}

var err error

if req.User.Ext == nil {
req.User.Ext, err = json.Marshal(openrtb_ext.ExtUser{Consent: p.Consent})
ext, err := json.Marshal(openrtb_ext.ExtUser{Consent: p.Consent})
if err == nil {
req.User.Ext = ext
}
return err
}

Expand Down

0 comments on commit 27e2e11

Please sign in to comment.