From f1b4c3a8429439429ece7fa7a77500128342674d Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 9 Oct 2019 08:03:39 +0200 Subject: [PATCH] Re-sanitize values on record update/create triggers Fixes #30 --- compose/service/record.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compose/service/record.go b/compose/service/record.go index ffced208b..e8910843b 100644 --- a/compose/service/record.go +++ b/compose/service/record.go @@ -327,6 +327,12 @@ func (svc record) Create(mod *types.Record) (r *types.Record, err error) { return } + // We do not know what happened in the before-create script, + // so we must sanitize values again before we store it + if r.Values, err = svc.sanitizeValues(m, r.Values); err != nil { + return + } + defer func() { // Run this at the end and discard the error _ = svc.sr.AfterRecordCreate(svc.ctx, ns, m, r) @@ -372,8 +378,14 @@ func (svc record) Update(mod *types.Record) (r *types.Record, err error) { mod = nil // make sure we do not use it anymore + // Calling before-record-update scripts if err = svc.sr.BeforeRecordUpdate(svc.ctx, ns, m, r); err != nil { - // Calling + return + } + + // We do not know what happened in the before-update script, + // so we must sanitize values again before we store it + if r.Values, err = svc.sanitizeValues(m, r.Values); err != nil { return }