Monorepo for Tangled tangled.org

appview: validate repo description length (max 140 chars) #1087

The description field had no length validation, so long descriptions would pass the form but fail at the DB INSERT (CHECK constraint) or lexicon layer (maxGraphemes: 140), after the PDS record and bare repo were already created. Add client-side maxlength and server-side rune count validation to reject early and avoid partial rollback state.

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:i2fgba5nignuw4nccml33wjp/sh.tangled.repo.pull/3mfljqqijsl22
+6 -1
Diff #0
+2 -1
appview/pages/templates/repo/new.html
··· 110 110 type="text" 111 111 id="description" 112 112 name="description" 113 + maxlength="140" 113 114 class="w-full w-full dark:bg-gray-700 dark:text-white dark:border-gray-600 border border-gray-300 rounded px-3 py-2" 114 115 placeholder="A brief description of your project..." 115 116 /> 116 117 <p class="text-sm text-gray-500 dark:text-gray-400 mt-1"> 117 - Optional. A short description to help others understand what your project does. 118 + Optional. A short description to help others understand what your project does (max 140 characters). 118 119 </p> 119 120 </div> 120 121 {{ end }}
+4
appview/state/state.go
··· 469 469 l = l.With("defaultBranch", defaultBranch) 470 470 471 471 description := r.FormValue("description") 472 + if len([]rune(description)) > 140 { 473 + s.pages.Notice(w, "repo", "Description must be 140 characters or fewer.") 474 + return 475 + } 472 476 473 477 // ACL validation 474 478 ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create")

History

1 round 1 comment
sign up or login to add to the discussion
1 commit
expand
appview: validate repo description length (max 140 chars)
expand 1 comment

lgtm thanks!

pull request successfully merged