diff --git a/cmd/server/repeater_handlers.go b/cmd/server/repeater_handlers.go index 17e29655..ad7f6889 100644 --- a/cmd/server/repeater_handlers.go +++ b/cmd/server/repeater_handlers.go @@ -142,11 +142,13 @@ func (s *Server) handleRepeaterInfoGet(w http.ResponseWriter, r *http.Request) { func (s *Server) handleRepeaterInfoList(w http.ResponseWriter, r *http.Request) { rows, err := s.auth.st.ListRepeaterInfo() if err != nil { + log.Printf("[users] list repeater info: %v", err) writeError(w, http.StatusInternalServerError, "internal error") return } claims, err := s.auth.st.AllRepeaterClaims() if err != nil { + log.Printf("[users] list repeater claims: %v", err) writeError(w, http.StatusInternalServerError, "internal error") return } diff --git a/internal/users/repeaters.go b/internal/users/repeaters.go index 22960c6a..a7e1aee5 100644 --- a/internal/users/repeaters.go +++ b/internal/users/repeaters.go @@ -72,7 +72,11 @@ func ValidateRepeaterEdit(e RepeaterEdit) (RepeaterEdit, error) { } return r }, n) - n = strings.TrimSpace(n) + lines := strings.Split(n, "\n") + for i, l := range lines { + lines[i] = strings.TrimRight(l, " ") + } + n = strings.TrimSpace(strings.Join(lines, "\n")) for strings.Contains(n, "\n\n\n") { n = strings.ReplaceAll(n, "\n\n\n", "\n\n") } diff --git a/internal/users/repeaters_test.go b/internal/users/repeaters_test.go index 85a51d76..b60461fb 100644 --- a/internal/users/repeaters_test.go +++ b/internal/users/repeaters_test.go @@ -59,6 +59,16 @@ func TestValidateRepeaterEdit(t *testing.T) { t.Fatalf("notes = %q", g.Notes) } }}, + {"notes whitespace-only lines count as blank", RepeaterEdit{Notes: "a\n \n\t\n \nb"}, false, func(t *testing.T, g RepeaterEdit) { + if g.Notes != "a\n\nb" { + t.Fatalf("notes = %q", g.Notes) + } + }}, + {"notes trailing spaces dropped per line", RepeaterEdit{Notes: "a \n b"}, false, func(t *testing.T, g RepeaterEdit) { + if g.Notes != "a\n b" { + t.Fatalf("notes = %q", g.Notes) + } + }}, {"notes single newline kept", RepeaterEdit{Notes: "a\nb"}, false, func(t *testing.T, g RepeaterEdit) { if g.Notes != "a\nb" { t.Fatalf("notes = %q", g.Notes) diff --git a/public/style.css b/public/style.css index 1381d791..b900626b 100644 --- a/public/style.css +++ b/public/style.css @@ -5967,7 +5967,7 @@ body.embed #app.app-fixed { /* Repeater info section (node detail views) */ #node-repeater-info, #node-repeater-info-pane { font-size: 13px; } .repeater-info-list { margin: 0 0 8px; } -.repeater-info-notes { white-space: pre-wrap; } +.repeater-info-notes { white-space: pre-wrap; max-height: 12em; overflow-y: auto; } .repeater-info-row { display: flex; gap: 8px; padding: 2px 0; } .repeater-info-row dt { flex: 0 0 120px; color: var(--text-muted); } .repeater-info-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } diff --git a/tests/e2e/test-user-management-e2e.js b/tests/e2e/test-user-management-e2e.js index f1474e56..90b96643 100644 --- a/tests/e2e/test-user-management-e2e.js +++ b/tests/e2e/test-user-management-e2e.js @@ -668,6 +668,11 @@ async function until(fn, label) { assert(t.indexOf('x') !== -1, 'notes not literal: ' + t); assert(t.indexOf('Last edited by Repeater A') !== -1, 'editor missing: ' + t); assert((await userA.locator(riSel + ' .repeater-info-notes b').count()) === 0, 'notes rendered as markup'); + const notesBox = await userA.locator(riSel + ' .repeater-info-notes').evaluate(function (n) { + var cs = getComputedStyle(n); + return { maxHeight: cs.maxHeight, overflowY: cs.overflowY }; + }); + assert(notesBox.maxHeight !== 'none' && notesBox.overflowY === 'auto', 'long notes are not capped: ' + JSON.stringify(notesBox)); }); await step('repeater info: A claims after the confirm and the button turns into Unclaim', async () => { diff --git a/tests/unit/test-repeater-info.js b/tests/unit/test-repeater-info.js index 28676f17..d62d3644 100644 --- a/tests/unit/test-repeater-info.js +++ b/tests/unit/test-repeater-info.js @@ -65,7 +65,7 @@ test('notes render as text, never markup', () => { assert(h.includes('<img'), h); assert(!h.includes(' { const h = T.viewHtml(INFO({ claimers: [{ displayName: XSS }] }), USER);