feat(kb): validate slug/tags and cap text fields on article form #224

Merged
nrupard merged 3 commits from feat/mapps-218-kb-article-form-validation into main 2026-06-16 16:54:48 +02:00
Owner

The New KB Article form stored a user-supplied slug verbatim (spaces, <>, punctuation), accepted unbounded tags including markup like <script>, and set no maxlength on the text fields. This normalizes the slug, sanitizes tags, and caps field lengths so invalid data never reaches the API (MAPPS-218).

Slug: at submit the author-entered value (or the title-derived fallback) now always passes through slugify, which is idempotent on an already-valid slug, so the stored value is always lowercase, hyphen-separated, and free of spaces/<>/punctuation.

Tags: a new sanitize_tags helper strips markup (</>) and control characters, trims, caps each tag at TAG_MAX (50) characters, and drops empties, replacing the previous trim-and-split that stored garbage tags verbatim.

maxlength: Title, Slug, and Summary inputs and the Body textarea now carry client maxlength caps mirroring the server's KB article column limits, so over-long input is blocked at the field rather than failing as an opaque 422.

Adds unit tests for the slug normalization and tag sanitization paths.

#MAPPS-218

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

The New KB Article form stored a user-supplied slug verbatim (spaces, `<>`, punctuation), accepted unbounded tags including markup like `<script>`, and set no `maxlength` on the text fields. This normalizes the slug, sanitizes tags, and caps field lengths so invalid data never reaches the API (MAPPS-218). Slug: at submit the author-entered value (or the title-derived fallback) now always passes through `slugify`, which is idempotent on an already-valid slug, so the stored value is always lowercase, hyphen-separated, and free of spaces/`<>`/punctuation. Tags: a new `sanitize_tags` helper strips markup (`<`/`>`) and control characters, trims, caps each tag at `TAG_MAX` (50) characters, and drops empties, replacing the previous trim-and-split that stored garbage tags verbatim. maxlength: Title, Slug, and Summary inputs and the Body textarea now carry client `maxlength` caps mirroring the server's KB article column limits, so over-long input is blocked at the field rather than failing as an opaque 422. Adds unit tests for the slug normalization and tag sanitization paths. #MAPPS-218 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
feat(kb): validate slug/tags and cap text fields on article form
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m3s
51a9f181b3
The New KB Article form stored a user-supplied slug verbatim (spaces, `<>`, punctuation), accepted unbounded tags including markup like `<script>`, and set no `maxlength` on the text fields. This normalizes the slug, sanitizes tags, and caps field lengths so invalid data never reaches the API (MAPPS-218).

Slug: at submit the author-entered value (or the title-derived fallback) now always passes through `slugify`, which is idempotent on an already-valid slug, so the stored value is always lowercase, hyphen-separated, and free of spaces/`<>`/punctuation.

Tags: a new `sanitize_tags` helper strips markup (`<`/`>`) and control characters, trims, caps each tag at `TAG_MAX` (50) characters, and drops empties, replacing the previous trim-and-split that stored garbage tags verbatim.

maxlength: Title, Slug, and Summary inputs and the Body textarea now carry client `maxlength` caps mirroring the server's KB article column limits, so over-long input is blocked at the field rather than failing as an opaque 422.

Adds unit tests for the slug normalization and tag sanitization paths.

#MAPPS-218

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix(kb): pass Body maxlength as i64 after the Textarea unify
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 59s
Create release / Create release from merged PR (pull_request) Has been skipped
3af4ba48f0
This branch predated MAPPS-219, which unified `Textarea::maxlength` to `Option<i64>`. The Body (Markdown) field still passed `BODY_MAX.to_string()`, which no longer matches the prop type after merging main. Pass the cap as `i64` like every other maxlength call site.

#MAPPS-218
nrupard deleted branch feat/mapps-218-kb-article-form-validation 2026-06-16 16:54:48 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!224
No description provided.