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
scout/forge:scout/5067-a-form-error-on-the-account-page-is-5-s → main 3 commits fork 1 thread · 1 unresolved
3 files
changed +15
−8
src/web/pages/account.ts +3 −6
| @@ -48,7 +48,7 @@ import { | ||
| 48 | 48 | } from "../chrome.ts"; |
| 49 | 49 | import { accountSections } from "./origins.ts"; |
| 50 | 50 | import { field, readForm } from "../form.ts"; |
| 51 | import { html, when, type Html } from "../html.ts"; | |
| 51 | import { html, type Html } from "../html.ts"; | |
| 52 | 52 | import { flashTo, page } from "../layout.ts"; |
| 53 | 53 | import { |
| 54 | 54 | badge, |
| @@ -112,9 +112,9 @@ function notifyView(ctx: Ctx, error?: string): Html { | ||
| 112 | 112 | const host = notifyHost(notifyUrlOf(ctx.app.db, ctx.auth.user!.id)); |
| 113 | 113 | return card( |
| 114 | 114 | html`<form method="post" action="/settings/notify"> |
| 115 | ${when(error, (m) => html`<p class="error-note">${m}</p>`)} | |
| 116 | 115 | ${uiField({ |
| 117 | 116 | label: "Notify URL", |
| 117 | ...(error ? { error } : {}), | |
| 118 | 118 | name: "url", |
| 119 | 119 | type: "url", |
| 120 | 120 | autocomplete: "off", |
| @@ -819,10 +819,6 @@ function keysView( | ||
| 819 | 819 | )} |
| 820 | 820 | ${card( |
| 821 | 821 | html`<form method="post" action="/settings/keys"> |
| 822 | ${when( | |
| 823 | values.error, | |
| 824 | (message) => html`<p class="error-note">${message}</p>`, | |
| 825 | )} | |
| 826 | 822 | ${uiField({ |
| 827 | 823 | label: "Name", |
| 828 | 824 | name: "name", |
| @@ -831,6 +827,7 @@ function keysView( | ||
| 831 | 827 | })} |
| 832 | 828 | ${uiField({ |
| 833 | 829 | label: "Public key", |
| 830 | ...(values.error ? { error: values.error } : {}), | |
| 834 | 831 | name: "key", |
| 835 | 832 | type: "textarea", |
| 836 | 833 | rows: 4, |
test/keys.test.ts +6 −1
| @@ -309,7 +309,12 @@ describe.skipIf(NO_KEYGEN)("ssh keys", () => { | ||
| 309 | 309 | redirect: "manual", |
| 310 | 310 | }); |
| 311 | 311 | 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(?:'|')t look like/, | |
| 317 | ); | |
| 313 | 318 | |
| 314 | 319 | // Cross-origin submissions are refused like every other form. |
| 315 | 320 | const csrf = await fetch(`${base}/settings/keys/${key!.id}/delete`, { |
test/notify.test.ts +6 −1
| @@ -248,7 +248,12 @@ describe("the account page", () => { | ||
| 248 | 248 | test("an http: URL is refused and nothing is stored; a good one is stored and only its host shown", async () => { |
| 249 | 249 | const refused = await save("http://ntfy.example.test/t"); |
| 250 | 250 | 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 | ); | |
| 252 | 257 | expect(notifyUrlOf(app.db, alice.id)).toBeUndefined(); |
| 253 | 258 | |
| 254 | 259 | const saved = await save(secret); |
new above
offline
Matches a raw apostrophe, but the output is escaped to '. Use
That doesn(?:'|')t look likeor anchor onsupported public key.