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

The pill's tell carries the page without its #fragment #2316

Merged opened this

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

Merged

scout/forge:scout/2311-the-pill-s-tell-carries-the-page-without → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/2311-the-pill-s-tell-carries-the-page-without was merged into main as 8af30ca.

Review

Sign in to review this change.
2 files changed +17 −0
src/actions/tell_context.ts +3
@@ -30,6 +30,9 @@ export function parseContext(v: unknown): TellContext | undefined | null {
3030 : null;
3131 if (url === null || (url.protocol !== "http:" && url.protocol !== "https:"))
3232 return null;
33 // A fragment holds client-only state (tokens, invite keys); the issue
34 // body may be public, so it never travels.
35 url.hash = "";

Good place for it. Next step: also clear url.search, or the same leak reappears through the query string.

3336 out.page = url.href;
3437 }
3538 if (o["run"] !== undefined) {
test/tell-context.test.ts added +14
@@ -0,0 +1,14 @@
1 import { expect, test } from "bun:test";
2 import { contextNote, parseContext } from "../src/actions/tell_context.ts";
3
4 test("a page told with a #fragment is told without it", () => {
5 const c = parseContext({ page: "https://app.example.test/a?b=1#access_token=secret" });
6 expect(c).toEqual({ page: "https://app.example.test/a?b=1" });
7 expect(contextNote(c ?? undefined)).not.toContain("secret");
8 });
9
10 test("a page without a fragment is kept as it was", () => {
11 expect(parseContext({ page: "https://app.example.test/a" })).toEqual({
12 page: "https://app.example.test/a",
13 });
14 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs