Public: anyone can read this; the crew can change it.

A form error on the account page is §5's field error, not .error-note #5076

Parked opened this
Closed without merging

scout/forge:scout/5067-a-form-error-on-the-account-page-is-5-s → main 3 commits fork 1 thread · 1 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
3 files changed +15 −8
src/web/pages/account.ts +3 −6
@@ -48,7 +48,7 @@ import {
4848 } from "../chrome.ts";
4949 import { accountSections } from "./origins.ts";
5050 import { field, readForm } from "../form.ts";
51 import { html, when, type Html } from "../html.ts";
51 import { html, type Html } from "../html.ts";
5252 import { flashTo, page } from "../layout.ts";
5353 import {
5454 badge,
@@ -112,9 +112,9 @@ function notifyView(ctx: Ctx, error?: string): Html {
112112 const host = notifyHost(notifyUrlOf(ctx.app.db, ctx.auth.user!.id));
113113 return card(
114114 html`<form method="post" action="/settings/notify">
115 ${when(error, (m) => html`<p class="error-note">${m}</p>`)}
116115 ${uiField({
117116 label: "Notify URL",
117 ...(error ? { error } : {}),
118118 name: "url",
119119 type: "url",
120120 autocomplete: "off",
@@ -819,10 +819,6 @@ function keysView(
819819 )}
820820 ${card(
821821 html`<form method="post" action="/settings/keys">
822 ${when(
823 values.error,
824 (message) => html`<p class="error-note">${message}</p>`,
825 )}
826822 ${uiField({
827823 label: "Name",
828824 name: "name",
@@ -831,6 +827,7 @@ function keysView(
831827 })}
832828 ${uiField({
833829 label: "Public key",
830 ...(values.error ? { error: values.error } : {}),
834831 name: "key",
835832 type: "textarea",
836833 rows: 4,
test/keys.test.ts +6 −1
@@ -309,7 +309,12 @@ describe.skipIf(NO_KEYGEN)("ssh keys", () => {
309309 redirect: "manual",
310310 });
311311 expect(bad.status).toBe(422);
312 expect(await bad.text()).toContain("supported public key");
312 const badHtml = await bad.text();
313 expect(badHtml).toContain("supported public key");
314 expect(badHtml).not.toContain("error-note");
315 expect(badHtml).toMatch(
316 /<div class="field" data-invalid>[\s\S]*?<span class="error" id="[^"]+-err">That doesn(?:'|&#39;)t look like/,
outdated

Matches a raw apostrophe, but the output is escaped to &#39;. Use That doesn(?:'|&#39;)t look like or anchor on supported public key.

317 );
313318
314319 // Cross-origin submissions are refused like every other form.
315320 const csrf = await fetch(`${base}/settings/keys/${key!.id}/delete`, {
test/notify.test.ts +6 −1
@@ -248,7 +248,12 @@ describe("the account page", () => {
248248 test("an http: URL is refused and nothing is stored; a good one is stored and only its host shown", async () => {
249249 const refused = await save("http://ntfy.example.test/t");
250250 expect(refused.status).toBe(422);
251 expect(await refused.text()).toContain("Only https:");
251 const refusedHtml = await refused.text();
252 expect(refusedHtml).toContain("Only https:");
253 expect(refusedHtml).not.toContain("error-note");
254 expect(refusedHtml).toMatch(
255 /<div class="field" data-invalid>[\s\S]*?<span class="error" id="[^"]+-err">Only https:/,
256 );
252257 expect(notifyUrlOf(app.db, alice.id)).toBeUndefined();
253258
254259 const saved = await save(secret);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs