feat(17-01): richeditor field type on the seaglass sanitizer
- seaglass (new module): bluemonday v1.0.27 policy ported from Journal without the Blog Editor rules, byte-stable token comparison, SanitizeReport, Sanitize, Check, Removals - cabana: type richeditor (common keys plus size); every create and update value sanitized before Fill, non-string values are a 422, removals become meta.notices; settings and relation forms refuse the type - backend lang richeditor.removed_* and markup_changed (en, pl plurals) - TestSeaglassSmoke, TestCompanionsRichEditorSmoke, README and docs
This commit is contained in:
@@ -607,6 +607,11 @@ func (s CRUDService) save(ctx context.Context, cc *CompiledController, id any, i
|
||||
// Plugin field values are lifted the same way and decoded by their type
|
||||
// inside the transaction, once the record is loaded.
|
||||
pluginValues := liftPluginValues(cc, in.Body, op)
|
||||
// A richeditor value is a string or null; anything else is refused on
|
||||
// the field instead of being dropped by the projection.
|
||||
if err := checkRichEditorValues(cc, in.Body, op); err != nil {
|
||||
return RecordResult{}, err
|
||||
}
|
||||
var (
|
||||
result RecordResult
|
||||
notices []pluginNotice
|
||||
@@ -631,7 +636,8 @@ func (s CRUDService) save(ctx context.Context, cc *CompiledController, id any, i
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
notices = decoded.notices
|
||||
// D-10: every richeditor value is sanitized before Fill sees it.
|
||||
notices = append(decoded.notices, sanitizeRichEditors(cc, projected)...)
|
||||
// The Form hooks read what this save writes for plugin field types.
|
||||
ctx = withFieldWrites(ctx, decoded.writes)
|
||||
if err := lagoon.Fill(target, fillAllowed(cc, target, op), projected, false); err != nil {
|
||||
@@ -1244,7 +1250,7 @@ func modelColumns(model any) map[string]struct{} {
|
||||
func scalarFormField(typ string) bool {
|
||||
switch typ {
|
||||
case "text", "textarea", "number", "checkbox", "switch", "dropdown", "datepicker",
|
||||
"markdown", "mltext", "mltextarea", "mlmarkdown":
|
||||
"markdown", "mltext", "mltextarea", "mlmarkdown", "richeditor":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user