fix(repeater-info): log bulk read errors, cap long notes (#2416)

Follow-up to #2415, see #2414.
This commit is contained in:
efiten authored and GitHub committed 2026-11-17 12:56:27 +01:00
1 parent 0cf22cdd79
commit af732d18aa
6 files changed
+24 -3

No files matched your search

+2
View File
@@ -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
}
+5 -1
View File
@@ -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")
}
+10
View File
@@ -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)
+1 -1
View File
@@ -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; }
+5
View File
@@ -668,6 +668,11 @@ async function until(fn, label) {
assert(t.indexOf('<b>x</b>') !== -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 () => {
+1 -1
View File
@@ -65,7 +65,7 @@ test('notes render as text, never markup', () => {
assert(h.includes('&lt;img'), h);
assert(!h.includes('<img'), h);
assert(h.includes('repeater-info-notes'));
assert(src('public/style.css').includes('.repeater-info-notes { white-space: pre-wrap; }'));
assert(src('public/style.css').includes('.repeater-info-notes { white-space: pre-wrap; max-height: 12em; overflow-y: auto; }'));
});
test('display names are escaped', () => {
const h = T.viewHtml(INFO({ claimers: [{ displayName: XSS }] }), USER);