Monorepo for Tangled

appview: validate repo description length (max 140 chars)

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.

authored by

Russ T Fugal and committed by tangled.org 4a3b21b4 d82f05f8

+6 -1
+2 -1
appview/pages/templates/repo/new.html
··· 110 type="text" 111 id="description" 112 name="description" 113 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 placeholder="A brief description of your project..." 115 /> 116 <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 </p> 119 </div> 120 {{ end }}
··· 110 type="text" 111 id="description" 112 name="description" 113 + maxlength="140" 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" 115 placeholder="A brief description of your project..." 116 /> 117 <p class="text-sm text-gray-500 dark:text-gray-400 mt-1"> 118 + Optional. A short description to help others understand what your project does (max 140 characters). 119 </p> 120 </div> 121 {{ end }}
+4
appview/state/state.go
··· 469 l = l.With("defaultBranch", defaultBranch) 470 471 description := r.FormValue("description") 472 473 // ACL validation 474 ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create")
··· 469 l = l.With("defaultBranch", defaultBranch) 470 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 + } 476 477 // ACL validation 478 ok, err := s.enforcer.E.Enforce(user.Active.Did, domain, domain, "repo:create")