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

A tell sent from the toolbar carries the page, the app, the version and the selected text #15775

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/15750-a-tell-sent-from-the-toolbar-carries-the → main 0 commits fork

  • Merged. scout/15750-a-tell-sent-from-the-toolbar-carries-the was merged into main as 3ee014b.

Review

Sign in to review this change.
11 files changed +207 −14
docs/features/tell-context-row.md added +13
@@ -0,0 +1,13 @@
1 ---
2 topic: Tell the crew
3 row: A tell sent from the toolbar says the page, app, version and selected text it carries, and one tap leaves them off
4 ---
5 # What a toolbar tell carries (#15750)
6
7 The tell box in the forge toolbar has a row above Send: "Sent with it: /cart · shop · a1b2c3d · "the selected words"". It is what goes with your words, shown before you send.
8
9 - Sent: the page address, the app, the live version (short commit), the viewport, the last console errors and the text you had selected when you opened the toolbar (up to 500 characters, shown cut to 60).
10 - Leave it off: untick the box. The row turns to "Left off: ..." and the request is only your words (`{text, bare: true}`); the issue has no Context fold and no quote.
11 - The issue quotes the selection under "Selected on the page:" with markup, mentions, `#` references, links and emphasis defused, so a quote never pings, links or cross-references anyone.
12 - After a send the selection is dropped; the next tell takes a new one. The row is `aria-live="polite"`, so a screen reader hears it change when the selection is captured.
13 - Code: `src/apps/toolbar.ts`, `src/apps/feedback.ts`, `src/actions/note_context.ts`; tests in `test/toolbar-tell-context.test.ts`, `test/apps-feedback.test.ts`, `test/apps-toolbar-draft.test.ts`.
src/actions/app_notes.ts +4 −1
@@ -204,6 +204,8 @@ export interface NoteInput {
204204 readonly viewport: string;
205205 /** Path, build and console errors, already checked (`parseNoteContext`). */
206206 readonly context?: NoteContext;
207 /** The sender left the context off: no page, build or selection goes with the words. */
208 readonly bare?: boolean;
207209 }
208210
209211 /**
@@ -256,7 +258,8 @@ export async function sendNote(
256258 "",
257259 `- Source: app \`${record.slug}\`, environment \`${env}\`${pullOfEnv === undefined ? "" : `, previews pull [#${pullOfEnv}](/${owner.username}/${repo.name}/pulls/${pullOfEnv})`}`,
258260 `- Time: ${new Date().toISOString()}`,
259 ].join("\n") + contextFold(input.context ?? { build: "", errors: [] }, { page: input.page, viewport: input.viewport });
261 ].join("\n") +
262 (input.bare === true ? "" : contextFold(input.context ?? { build: "", errors: [] }, { page: input.page, viewport: input.viewport }));
260263 // The label exists before the issue does, so a mirror's origin can apply it too.
261264 if (getLabel(app.db, repo.id, FROM_APP_LABEL) === undefined) createLabel(app.db, repo.id, FROM_APP_LABEL, LABEL_COLOR);
262265 const unavailable = err({ error: "unavailable", message: "The builders cannot take notes right now." } as const);
src/actions/note_context.ts +19 −3
@@ -11,7 +11,10 @@
1111 export interface NoteContext {
1212 readonly build: string;
1313 readonly errors: readonly string[];
14 /** The text the sender had selected on the page, cut short and cleaned. */
15 readonly selected?: string;
1416 }
17 export const SELECTED_MAX = 500;
1518
1619 export const ERRORS_MAX = 5;
1720 export const ERROR_CHARS = 200;
@@ -36,7 +39,7 @@ export function scrubMessage(raw: string): string {
3639 * the client's word), `errors` what the client sent. Anything malformed is dropped,
3740 * never an error: the note itself still goes.
3841 */
39 export function parseNoteContext(errors: unknown, build: string | undefined): NoteContext {
42 export function parseNoteContext(errors: unknown, build: string | undefined, selected?: unknown): NoteContext {
4043 const list: string[] = [];
4144 if (Array.isArray(errors)) {
4245 for (const e of errors.slice(0, ERRORS_MAX)) {
@@ -45,7 +48,15 @@ export function parseNoteContext(errors: unknown, build: string | undefined): No
4548 if (m !== "") list.push(m);
4649 }
4750 }
48 return { build: build !== undefined && BUILD.test(build) ? build : "", errors: list };
51 const sel =
52 typeof selected === "string"
53 ? scrubMessage(selected.slice(0, 4 * SELECTED_MAX)).slice(0, SELECTED_MAX)
54 : "";
55 return {
56 build: build !== undefined && BUILD.test(build) ? build : "",
57 errors: list,
58 ...(sel === "" ? {} : { selected: sel }),
59 };
4960 }
5061
5162 /**
@@ -63,5 +74,10 @@ export function contextFold(c: NoteContext, where: { page?: string; viewport?: s
6374 ...c.errors.map((e) => `- Console error: \`${e.replace(/`/g, "'")}\``),
6475 ].filter((l) => l !== "");
6576 if (lines.length === 0) return "";
66 return ["", "<details><summary>Context</summary>", ...lines, "</details>"].join("\n");
77 // The selection is the sender's words from a page, unchecked: a quoted block, markup defused.
78 const quote =
79 c.selected === undefined || c.selected === ""
80 ? []
81 : ["", "Selected on the page:", "", `> ${c.selected.replace(/[<>&`@#\[\]()!:*_~\\|]/g, (ch) => `&#${ch.charCodeAt(0)};`)}`];
82 return ["", "<details><summary>Context</summary>", ...lines, ...quote, "</details>"].join("\n");
6783 }
src/apps/feedback.ts +6 −3
@@ -246,15 +246,18 @@ async function send(ask: FeedbackAsk, door: Door): Promise<Response> {
246246 if (body === undefined) return json(400, { error: "bad_request", message: NOTE_FAILED });
247247 const { sender, fresh } = senderOf(ask, door);
248248 const cookies = fresh === undefined ? {} : { "set-cookie": visitorCookie(fresh, ask.secure) };
249 const page = pageOf(body.page, request.headers.get("host"), new URL(request.url).origin);
250 const viewport = typeof body.viewport === "string" && /^\d{2,5}x\d{2,5}$/.test(body.viewport) ? body.viewport : "unknown";
249 // The sender took the context off: only their words go.
250 const bare = body.bare === true;
251 const page = bare ? "" : pageOf(body.page, request.headers.get("host"), new URL(request.url).origin);
252 const viewport = !bare && typeof body.viewport === "string" && /^\d{2,5}x\d{2,5}$/.test(body.viewport) ? body.viewport : "unknown";
251253 const sent = await sendNote(
252254 ask.app, ask.record, door.repo, ask.env, ask.forgeUrl, sender,
253255 {
254256 text: typeof body.text === "string" ? body.text : "",
255257 page,
256258 viewport,
257 context: parseNoteContext(body.errors, ask.build),
259 ...(bare ? {} : { context: parseNoteContext(body.errors, ask.build, body.selected) }),
260 ...(bare ? { bare: true } : {}),
258261 },
259262 ask.source,
260263 door.viewer,
src/apps/toolbar.ts +27 −1
@@ -15,6 +15,7 @@
1515 */
1616
1717 import { staticResponse } from "../web/asset.ts";
18 import { SELECTED_MAX } from "../actions/note_context.ts";
1819 import { TELL_TEXT_MAX } from "../actions/tell_from.ts";
1920 import { sha256 } from "../kernel/hash.ts";
2021 import { TOUR_ASSET_PATH } from "./tour.ts";
@@ -234,6 +235,27 @@ const toolbarSource = `(function () {
234235 tellText.oninput();
235236 tellPicRow.appendChild(tellPic);
236237 tellPicRow.appendChild(tellPicText);
238 // What goes with the tell, shown before it is sent; one tap leaves it off.
239 var picked = "";
240 function selectedText() {
241 try { return String(getSelection()).replace(/\\s+/g, " ").trim().slice(0, ${SELECTED_MAX}); } catch (e) { return ""; }
242 }
243 var tellCtxRow = document.createElement("label");
244 tellCtxRow.style.cssText = "display:flex;gap:8px;min-height:44px;overflow-wrap:anywhere";
245 var tellCtx = document.createElement("input");
246 tellCtx.type = "checkbox";
247 tellCtx.checked = true;
248 var tellCtxText = document.createElement("span");
249 tellCtxText.setAttribute("aria-live", "polite");
250 tellCtxRow.appendChild(tellCtx);
251 tellCtxRow.appendChild(tellCtxText);
252 function showContext() {
253 var p = "";
254 try { p = location.pathname || ""; } catch (e) {}
255 tellCtxText.textContent = (tellCtx.checked ? "Sent with it: " : "Left off: ") + [p.slice(0, 60), d.app, (d.commit || "").slice(0, 7), picked && "\u201c" + picked.slice(0, 60) + "\u201d"].filter(Boolean).join(" \u00b7 ") + ". Untick to send only your words.";
256 }
257 tellCtx.onchange = showContext;
258 showContext();
237259 var tellGo = document.createElement("button");
238260 tellGo.type = "submit";
239261 tellGo.textContent = "Send";
@@ -249,6 +271,7 @@ const toolbarSource = `(function () {
249271 tellBox.appendChild(tellHead);
250272 tellBox.appendChild(tellHint);
251273 tellBox.appendChild(tellText);
274 tellBox.appendChild(tellCtxRow);
252275 tellBox.appendChild(tellPicRow);
253276 tellBox.appendChild(tellGo);
254277 tellBox.appendChild(tellSay);
@@ -396,7 +419,7 @@ const toolbarSource = `(function () {
396419 method: "POST",
397420 credentials: "same-origin",
398421 headers: { "content-type": "application/json" },
399 body: JSON.stringify({ text: text, page: location.href, viewport: window.innerWidth + "x" + window.innerHeight, errors: errs.slice(-5) })
422 body: JSON.stringify(tellCtx.checked ? { text: text, page: location.href, viewport: window.innerWidth + "x" + window.innerHeight, errors: errs.slice(-5), selected: picked } : { text: text, bare: true })
400423 })
401424 .then(function (r) { return r.json().catch(function () { return null; }).then(function (j) { return { ok: r.ok, s: r.status, w: r.headers.get("retry-after"), j: j }; }); })
402425 .then(function (a) {
@@ -414,6 +437,7 @@ const toolbarSource = `(function () {
414437 var a = x.a;
415438 if (a.ok) {
416439 tellText.value = "";
440 picked = ""; showContext();
417441 tellText.oninput();
418442 tellPic.checked = false;
419443 tellSay.textContent = wantPicture && x.pic !== true ? "Sent, without the picture. The builders will see it." : "Sent. The builders will see it.";
@@ -545,6 +569,7 @@ const toolbarSource = `(function () {
545569 place(corner);
546570 var drag = null, moved = false, until = 0;
547571 pill.addEventListener("pointerdown", function (e) {
572 if (panel.hidden) { picked = selectedText(); showContext(); }
548573 drag = { x: e.clientX, y: e.clientY, dx: 0, dy: 0 };
549574 moved = false;
550575 try { pill.setPointerCapture(e.pointerId); } catch (x) {}
@@ -641,6 +666,7 @@ const toolbarSource = `(function () {
641666 if (d.hidden === "1") { pill.style.display = "none"; tab.style.display = "block"; }
642667 panel.style.display = "none";
643668 function set(open) {
669 if (open && panel.hidden) { picked = selectedText() || picked; showContext(); }
644670 panel.hidden = !open;
645671 panel.style.display = open ? "flex" : "none";
646672 pill.setAttribute("aria-expanded", open ? "true" : "false");
test/apps-feedback.test.ts +16
@@ -169,6 +169,22 @@ describe("the forge button takes notes from anyone", () => {
169169 }
170170 });
171171
172 test("the route files the page and selection; a bare body files only the words (#15750)", async () => {
173 const send = async (body: Record<string, unknown>, source: string) => {
174 const res = await at("context", "/__forge/note", { method: "POST", body: JSON.stringify(body) }, "", source);
175 expect(res.status).toBe(201);
176 const j = (await res.json()) as { note: { url: string } };
177 return getIssue(app.db, getRepo(app.db, "alice", "context")!.id, Number(j.note.url.split("/").pop()))!.body;
178 };
179 const full = await send({ text: "It broke", page: `http://${host("context")}/cart`, viewport: "390x844", selected: "the <b>total</b> @bob #7" }, "10.7.1.1");
180 expect(full).toContain("Selected on the page:");
181 expect(full).toMatch(/^> the &#60;b&#62;total&#60;\/b&#62; &#64;bob &#35;7$/m);
182 expect(full).toContain("- Page:");
183 const bare = await send({ text: "Only words", bare: true, page: `http://${host("context")}/cart`, selected: "secret selection", errors: ["boom"] }, "10.7.1.2");
184 expect(bare).not.toMatch(/secret selection|Selected on the page|- Page:|- Viewport:|Console error/);
185 expect(bare).toContain("Only words");
186 });
187
172188 test("the sender sees their notes, and the status follows the issue", async () => {
173189 const first = await post("Add dark mode", "", "10.0.0.2");
174190 const cookie = cookieOf(first);
test/apps-toolbar-draft.test.ts +29 −3
@@ -8,7 +8,7 @@ import { toolbarJs } from "../src/apps/toolbar.ts";
88 import { NOTE_FAILED } from "../src/apps/note_words.ts";
99
1010 /** The toolbar budget of toolbar-budget.test.ts: 24 KB. */
11 const TOOLBAR_BYTE_BUDGET = 24 * 1024 + 256; // +256: the pull title (#15169)
11 const TOOLBAR_BYTE_BUDGET = 24 * 1024 + 1472; // +1216: the tell's context row (#15750)
1212 const HOSTILE = "<img src=x onerror=alert(1)>";
1313
1414 interface El { tag: string; children: El[]; listeners: Record<string, ((e: object) => void)[]>; [k: string]: any }
@@ -22,7 +22,7 @@ const make = (tag: string): El => ({
2222 });
2323
2424 /** Boot the script on a page; returns the tell field, the form and the elements it created. */
25 function boot(dataset: Record<string, string>, store: Record<string, string>, send: () => Promise<unknown> = () => new Promise(() => {})) {
25 function boot(dataset: Record<string, string>, store: Record<string, string>, send: (url?: string, init?: any) => Promise<unknown> = () => new Promise(() => {}), selection = "") {
2626 const created: El[] = [];
2727 const doc = {
2828 currentScript: { dataset: { forge: "https://forge.test", ...dataset } },
@@ -31,11 +31,14 @@ function boot(dataset: Record<string, string>, store: Record<string, string>, se
3131 referrer: "",
3232 body: { appendChild() {} },
3333 };
34 new Function("window", "document", "URL", "localStorage", "fetch", "location", toolbarJs)({ innerWidth: 400, innerHeight: 800, addEventListener() {} }, doc, URL, store, send, { href: "https://notes.test/" });
34 new Function("window", "document", "URL", "localStorage", "fetch", "location", "getSelection", toolbarJs)({ innerWidth: 400, innerHeight: 800, addEventListener() {} }, doc, URL, store, send, { href: "https://notes.test/cart", pathname: "/cart" }, () => selection);
3535 return {
3636 field: created.find((e) => e.tag === "textarea")!,
3737 form: created.find((e) => e.tag === "form")!,
3838 button: created.find((e) => e.tag === "button" && e.type === "submit")!,
39 box: created.find((e) => e.tag === "input" && e.type === "checkbox" && e.checked)!,
40 row: created.find((e) => e.tag === "span" && /^(Sent with it|Left off)/.test(e.textContent))!,
41 pill: created.find((e) => e.listeners.pointerdown)!,
3942 say: () => created.filter((e) => e.tag === "div" && /^(Sent|.*(try|again|offline))/i.test(e.textContent)).map((e) => e.textContent),
4043 count: () => created.length,
4144 tags: () => created.map((e) => e.tag),
@@ -119,3 +122,26 @@ test("a signed-out load restores nothing and clears the draft", () => {
119122 test("the script stays inside its budget", () => {
120123 expect(Buffer.byteLength(toolbarJs)).toBeLessThan(TOOLBAR_BYTE_BUDGET);
121124 });
125
126 test("the context row shows what goes with the tell; unticked, the request is only the words", async () => {
127 const sent: any[] = [];
128 const ok = (_u?: string, init?: any) => { sent.push(JSON.parse(init.body)); return Promise.resolve({ ok: true, status: 200, headers: { get: () => null }, json: async () => ({ note: { id: "n1", number: 1 } }) }); };
129 const p = boot({ ...preview, commit: "0123456789abcdef" }, {}, ok, "the total\nis wrong");
130 p.pill.listeners.pointerdown!.forEach((f) => f({ clientX: 0, clientY: 0 }));
131 expect(p.row.textContent).toContain("Sent with it: /cart · notes · 0123456 · \u201cthe total is wrong\u201d");
132 expect(p.row.textContent).toContain("Untick");
133 expect(p.row["aria-live"] ?? true).toBeTruthy();
134 typed(p.field, "fix this");
135 await submit(p);
136 expect(sent[0]).toMatchObject({ text: "fix this", page: "https://notes.test/cart", selected: "the total is wrong" });
137 // The selection went with that one tell, and the row no longer shows it.
138 expect(p.row.textContent).not.toContain("total");
139 const q = boot(preview, {}, ok, "secret");
140 q.pill.listeners.pointerdown!.forEach((f) => f({ clientX: 0, clientY: 0 }));
141 q.box.checked = false;
142 q.box.onchange();
143 expect(q.row.textContent).toStartWith("Left off: ");
144 typed(q.field, "just words");
145 await submit(q);
146 expect(sent[1]).toEqual({ text: "just words", bare: true });
147 });
test/apps-toolbar-state.test.ts +4 −1
@@ -38,12 +38,15 @@ const TITLE_ALLOWANCE = 170;
3838 // The toolbar's Make it yours saying why it cannot (a status, not a link), allowed by name: 40
3939 // bytes.
4040 const YOURS_WHY_ALLOWANCE = 50;
41 // The tell box's context row, shown before sending and left off in one tap (#15750), allowed by
42 // name: 1205 bytes.
43 const TELL_CONTEXT_ALLOWANCE = 1210;
4144 // Home on a preview is the app's page and checks the repo id more strictly (#15657), allowed by
4245 // name: 20 bytes.
4346 const HOME_ALLOWANCE = 30;
4447
4548 test("the addition stays under 300 bytes", () => {
46 expect(Buffer.byteLength(toolbarJs) - BASE_SCRIPT_BYTES).toBeLessThan(300 + DISMISSAL_ALLOWANCE + CHECK_SLOT_ALLOWANCE + TITLE_ALLOWANCE + YOURS_WHY_ALLOWANCE + HOME_ALLOWANCE);
49 expect(Buffer.byteLength(toolbarJs) - BASE_SCRIPT_BYTES).toBeLessThan(300 + DISMISSAL_ALLOWANCE + CHECK_SLOT_ALLOWANCE + TITLE_ALLOWANCE + YOURS_WHY_ALLOWANCE + TELL_CONTEXT_ALLOWANCE + HOME_ALLOWANCE);
4750 const tag = toolbarTag("https://forge.test", where("x".repeat(CHANGE_MAX)), "p", "n");
4851 const bare = toolbarTag("https://forge.test", where(), "p", "n");
4952 expect(Buffer.byteLength(tag) - Buffer.byteLength(bare)).toBeLessThan(300);
test/toolbar-budget.test.ts +1 −1
@@ -23,7 +23,7 @@ quietLogs();
2323 * The one budget (it loads on every app page): 24 KB, the script keeping the filed number and links
2424 * of #10560. Raising it is a decision, not a fix.
2525 */
26 export const TOOLBAR_BYTE_BUDGET = 24 * 1024 + 256; // +256: the pull's title beside its number (#15169)
26 export const TOOLBAR_BYTE_BUDGET = 24 * 1024 + 1472; // +1216: the tell's context row (#15750)
2727 /** The preview's comment box (#13664), fetched only when a preview's panel first opens. */
2828 export const COMMENT_BYTE_BUDGET = 4 * 1024;
2929
test/toolbar-size.test.ts +1 −1
@@ -12,7 +12,7 @@ import { toolbarJs, toolbarTag } from "../src/apps/toolbar.ts";
1212 * The limit, in bytes, of the toolbar's tag plus gzipped script. Raising it is a decision, not a
1313 * fix.
1414 */
15 export const TOOLBAR_WIRE_LIMIT = 8 * 1024 + 128; // +128: the pull's title beside its number (#15169)
15 export const TOOLBAR_WIRE_LIMIT = 8 * 1024 + 512; // +128 the pull title (#15169), +384 the tell context row (#15750)
1616
1717 test("the toolbar's injected bytes (tag plus gzipped script) stay under the stated limit", () => {
1818 const tag = toolbarTag("https://forge.test", { app: "notes", repo: "a/b", env: "preview", pull: 7 }, "proof", "n0nce");
test/toolbar-tell-context.test.ts added +87
@@ -0,0 +1,87 @@
1 /**
2 * A tell sent from the toolbar carries the page, the app, the live version and the selected text,
3 * shown to the sender first, removable in one tap, and quoted in the issue it opens (#15750).
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { newApp } from "../src/actions/apps.ts";
11 import { sendNote } from "../src/actions/app_notes.ts";
12 import { parseNoteContext, SELECTED_MAX } from "../src/actions/note_context.ts";
13 import { getAppBySlug } from "../src/core/apps.ts";
14 import { getIssue } from "../src/core/issues.ts";
15 import { getRepo } from "../src/core/repos.ts";
16 import { createUser, type User } from "../src/core/users.ts";
17 import { renderMarkdown } from "../src/web/markdown.ts";
18 import { quietLogs } from "./helpers/globals.ts";
19
20 quietLogs();
21
22 const BUILD = "a1b2c3d4e5f6";
23 let dataDir = "";
24 let app: App;
25 let owner: User;
26
27 beforeAll(async () => {
28 dataDir = await mkdtemp(join(tmpdir(), "forge-toolbar-tell-"));
29 app = createApp({ dataDir, port: 0, host: "forge.test" });
30 const made = await createUser(app.db, {
31 username: "alice", email: "[email protected]", password: "a-good-passphrase",
32 origin: "seed", trusted: true, adminIfFirst: true,
33 });
34 if (!made.ok) throw new Error(String(made.error));
35 owner = made.value;
36 const a = await newApp(app, owner, { name: "shop", description: "Words", visibility: "public" });
37 if (!a.ok) throw new Error(String(a.error));
38 });
39 afterAll(async () => {
40 app.close();
41 await rm(dataDir, { recursive: true, force: true, maxRetries: 20, retryDelay: 100 });
42 });
43
44 async function send(input: Parameters<typeof sendNote>[6]) {
45 const repo = getRepo(app.db, "alice", "shop")!;
46 const sent = await sendNote(app, getAppBySlug(app.db, "shop")!, repo, "production", undefined,
47 { key: `u:${owner.id}`, name: "alice", person: true }, input, "10.9.0.1");
48 if (!sent.ok) throw new Error(sent.error.message);
49 return getIssue(app.db, repo.id, sent.value.number)!;
50 }
51
52 test("the issue shows page, version and the selection as a quoted block, defused", async () => {
53 const context = parseNoteContext([], BUILD, "the <b>total</b> is wrong `x`");
54 const issue = await send({ text: "fix this", page: "http://shop.test/cart", viewport: "390x844", context });
55 expect(issue.body).toContain("- Page: `http://shop.test/cart`");
56 expect(issue.body).toContain(`- Build: \`${BUILD}\``);
57 expect(issue.body).toContain("shop");
58 expect(issue.body).toMatch(/^> the &#60;b&#62;total&#60;\/b&#62; is wrong &#96;x&#96;$/m);
59 const html = String(renderMarkdown(issue.body));
60 expect(html).toContain("<blockquote>");
61 expect(html).not.toContain("<b>total");
62 });
63
64 test("the selection is capped", () => {
65 const c = parseNoteContext([], BUILD, "w".repeat(50000));
66 expect(c.selected!.length).toBe(SELECTED_MAX);
67 expect(parseNoteContext([], BUILD, 42).selected).toBeUndefined();
68 });
69
70 test("a bare tell carries no context at all", async () => {
71 const issue = await send({ text: "just words", page: "", viewport: "unknown", bare: true,
72 context: parseNoteContext([], BUILD, "secret selection") });
73 expect(issue.body).not.toContain("Context");
74 expect(issue.body).not.toContain("secret selection");
75 expect(issue.body).not.toContain(BUILD);
76 });
77
78 test("a selection cannot ping, link or cross-reference from the quote", async () => {
79 const sel = "@someone #123 owner/repo#4 [x](http://evil.test) https://evil.test **b** ![i](u)";
80 const issue = await send({ text: "look", page: "http://shop.test/", viewport: "390x844", context: parseNoteContext([], BUILD, sel) });
81 const quote = issue.body.split("\n").find((l) => l.startsWith("> "))!;
82 expect(quote.replace(/&#\d+;/g, "")).not.toMatch(/[@#\[\]()*!:_]/);
83 const html = String(renderMarkdown(issue.body));
84 const block = html.slice(html.indexOf("<blockquote>"), html.indexOf("</blockquote>"));
85 expect(block).toContain("someone");
86 expect(block).not.toMatch(/<(a|img|strong|em)[ >]/);
87 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs