Skip to content

Commit 6de1ab4

Browse files
matt2eclaude
andauthored
fix(navigation): ignore unknown query parameters on Buzz links and remove the buzz://open locator (#457)
Signed-off-by: Matt Toohey <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent d5d493f commit 6de1ab4

20 files changed

Lines changed: 299 additions & 320 deletions

‎docs/deep-links.md‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ The OS ingress accepts the Buzz link forms and nothing else:
2525
Entity sections are `files`, `commits`, `issues`, `prs`, `contributors`, and
2626
`channels`; omitting the section opens the overview. Repository commit links add
2727
`&tab=commits&commit=<40- or 64-hex hash>`. Identifiers use 1-64 ASCII letters,
28-
digits, `_`, `-`, or `.`, without a leading dot or `..`. Unknown or duplicate
29-
parameters are rejected. The same forms work in message content.
28+
digits, `_`, `-`, or `.`, without a leading dot or `..`. Query parameters outside
29+
a form's grammar are ignored, with their values and any repeats, so a link that
30+
another client decorated still opens; a duplicated known parameter is rejected as
31+
ambiguous. The `channel` forms carry everything in the path and ignore any query.
32+
The same forms work in message content.
3033

3134
None carries a community, so each binds to the currently selected community and
3235
viewer, and fail `unavailable` when no community is selected or no identity is
33-
known. Every other link, including `buzz://open?target=…`, `buzz://join`,
34-
incomplete entity links, unknown hosts and oversize links, fails as
35-
`invalid-target` and shows "This destination couldn't open" with
36-
**Open Settings**. Unsupported links have no Retry action. Nothing is
37-
auto-joined. A valid address is never authorization: bound targets pass the same
38-
viewer, membership and channel checks as in-app navigation, so a link into a channel
39-
you cannot read still fails `denied`. The frontend expects the canonical lowercase
40-
`buzz:` scheme; the native URL parser can normalize scheme case before delivery,
41-
so uppercase OS input is not guaranteed to be rejected.
36+
known. Every other link, including `buzz://join`, incomplete entity links,
37+
unknown hosts and oversize links, fails as `invalid-target` and shows "This
38+
destination couldn't open" with **Open Settings**. Unsupported links have no
39+
Retry action. Nothing is auto-joined. A valid address is never authorization:
40+
bound targets pass the same viewer, membership and channel checks as in-app
41+
navigation, so a link into a channel you cannot read still fails `denied`. The
42+
frontend expects the canonical lowercase `buzz:` scheme; the native URL parser
43+
can normalize scheme case before delivery, so uppercase OS input is not
44+
guaranteed to be rejected.
4245

4346
The latest arriving link wins. Before readiness, one pending intent is retained;
4447
if identity or community is missing, select a community and use **Retry navigation**.
@@ -61,8 +64,9 @@ explicit Git sections report navigation failure, not an empty successful page.
6164
This deliberately omits the sender's community and identity: recipients must select
6265
the correct community before opening it. Original mobile Buzz requires a UUID
6366
channel identifier; named development channels are supported here but do not imply
64-
mobile compatibility. Existing `buzz://open` locators still preserve community
65-
context for in-app use and remain unsupported at the OS boundary.
67+
mobile compatibility. The app has no link form of its own beyond the Buzz ones:
68+
unknown `buzz://` hosts are rejected everywhere, staying plain text in message
69+
content and failing `invalid-target` at the OS boundary.
6670

6771
## Testing locally
6872

‎docs/plugin-architecture.md‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,22 +489,21 @@ into versioned route parameters. These are host-matched preview types through
489489
`@buzz/author`, not a cross-version runtime compatibility promise.
490490

491491
Browser `#buzz=` addresses and session history support reload and Back/Forward.
492-
`targetLink`/`parseTargetLink` define a `buzz://open` locator codec that omits the
493-
sender's viewer; `bindSharedTarget` pins it for an admitted recipient. Messages also
494-
recognize the Buzz link forms `buzz://channel/<id>`, `buzz://channel/<id>/<event>` and
495-
`buzz://message?channel=<id>&id=<event>&thread=<optional-root>`. Buzz links use the
496-
receiving conversation's community and viewer; `buzz://open` locators retain their
497-
community and use the recipient's viewer. Both pass through existing navigation
498-
admission and session ownership checks. Message targets open their
492+
Messages recognize the Buzz link forms `buzz://channel/<id>`,
493+
`buzz://channel/<id>/<event>` and
494+
`buzz://message?channel=<id>&id=<event>&thread=<optional-root>`. Buzz links carry
495+
no community: they bind to the receiving conversation's community and viewer and
496+
pass through existing navigation admission and session ownership checks. The app
497+
has no link form of its own; any other `buzz://` host is rejected everywhere,
498+
staying plain text in messages. Message targets open their
499499
verified thread, reveal the exact message after bounded history loading, and only
500500
then acknowledge navigation. Supplied root hints do not override verified events.
501501
Missing or unavailable messages report failure. Ingress adapters must reuse this
502502
validated target/completion lifecycle; notification clicks
503503
([notifications](notifications.md)) and OS-delivered deep links on desktop
504504
([OS deep links](deep-links.md)) do. The OS ingress accepts only the Buzz link
505-
forms and binds them to the selected community; any other OS link, `buzz://open`
506-
included, fails `invalid-target` through the same failure notice rather than being
507-
dropped.
505+
forms and binds them to the selected community; any other OS link fails
506+
`invalid-target` through the same failure notice rather than being dropped.
508507

509508
Drafts, reading geometry and sidebar view intent remain domain-owned, outside
510509
visit history. Saved sidebar preferences live in the relay session, not in the

‎src/bundled/link-lab/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ it does not mark messages read. Other-community previews do not connect or switc
3232
communities on hover. Mentions with signed recipient IDs and unambiguous loaded
3333
names share the hover styling; known local agent identities use a robot icon.
3434
Known channel names in `#channel` text open through the same host link path.
35-
Both legacy channel/message links and versioned `buzz://open` links are supported.
35+
The Buzz link forms `buzz://channel/<id>`, `buzz://channel/<id>/<event>` and
36+
`buzz://message?channel=<id>&id=<event>[&thread=<root>]` are supported; any other
37+
`buzz://` host stays plain text.
3638
The host opens them through scoped navigation; message links reveal the selected
3739
message in its verified thread after bounded history loading. Missing targets
3840
report navigation failure. The lab only previews their appearance.

‎src/bundled/link-lab/index.tsx‎

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Field } from "../../shared/design-system/ui/Field";
22
import { Input } from "../../shared/design-system/ui/Input";
33
import { useState } from "react";
44
import type { PluginModule } from "../../plugins/api";
5-
import { targetLink } from "../../features/navigation/targets";
65
import { InlineLink, linkKind } from "../links/InlineLink";
76
import styles from "./LinkLab.module.css";
87

@@ -16,21 +15,12 @@ export const apply: PluginModule["apply"] = (ctx) => {
1615
});
1716
};
1817

19-
const buzz = targetLink({ version: 1, kind: "home" });
20-
const legacyChannel = "buzz://channel/c89a3185-29c5-40db-8284-054536d98b09";
21-
const legacyMessage =
18+
// The Buzz link forms: a channel, a message, and a reply inside a thread.
19+
const general = "buzz://channel/general";
20+
const thread = `buzz://message?channel=general&id=${"2".repeat(64)}&thread=${"2".repeat(64)}`;
21+
const uuidChannel = "buzz://channel/c89a3185-29c5-40db-8284-054536d98b09";
22+
const uuidMessage =
2223
"buzz://message?channel=c89a3185-29c5-40db-8284-054536d98b09&id=9a77911a6e94147b1ce2cdb3c4e87046c67a29f29f3dd25626134621a5f6924b";
23-
const thread = targetLink({
24-
version: 1,
25-
kind: "conversation",
26-
scope: {
27-
viewer: "1".repeat(64),
28-
communityOrigin: "wss://buzz.block.builderlab.xyz",
29-
},
30-
channelId: "general",
31-
messageId: "2".repeat(64),
32-
threadRootId: "2".repeat(64),
33-
});
3424

3525
const serviceSamples = [
3626
["Figma", "https://www.figma.com/design/example"],
@@ -128,13 +118,13 @@ function LinkLab() {
128118
Buzz channels, messages and threads
129119
</span>
130120
<p>
131-
Head back to {preview(buzz, "Buzz")} or pick up{" "}
121+
Head back to {preview(general, "#general")} or pick up{" "}
132122
{preview(thread, "the design discussion")}.
133123
</p>
134124
<p>
135-
Older shared links work too: {preview(legacyChannel)},{" "}
136-
{preview(legacyMessage)}, and{" "}
137-
{preview(`${legacyMessage}&thread=${"2".repeat(64)}`)}.
125+
Bare links show their kind: {preview(uuidChannel)},{" "}
126+
{preview(uuidMessage)}, and{" "}
127+
{preview(`${uuidMessage}&thread=${"2".repeat(64)}`)}.
138128
</p>
139129
</section>
140130
<section>

‎src/bundled/links/InlineLink.test.tsx‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,18 @@ import { expect, it } from "vitest";
22
import { renderToStaticMarkup } from "react-dom/server";
33
import { LockIcon, TableIcon } from "../../shared/design-system/icons/index";
44
import styles from "../../shared/InlineReference.module.css";
5-
import { targetLink } from "../../features/navigation/targets";
65
import { InlineLink, LinkLabel, linkKind } from "./InlineLink";
76
import {
87
LinkLabelContext,
98
LinkContentContext,
109
LinkChannelPrivateContext,
1110
} from "../../features/conversation/LinkLabelContext";
1211

13-
it("identifies exact GitHub hosts, ordinary websites, and valid Buzz locators", () => {
12+
it("identifies exact GitHub hosts, ordinary websites, and Buzz entity links", () => {
1413
expect(linkKind("https://github.com/block/buzz")).toBe("github");
1514
expect(linkKind("https://github.com.example.com/block/buzz")).toBe("web");
1615
expect(linkKind("https://example.com/github.com")).toBe("web");
17-
expect(linkKind(targetLink({ version: 1, kind: "home" }))).toBe("buzz");
18-
expect(
19-
linkKind(
20-
targetLink({
21-
version: 1,
22-
kind: "conversation",
23-
scope: {
24-
viewer: "1".repeat(64),
25-
communityOrigin: "https://example.com",
26-
},
27-
channelId: "general",
28-
messageId: "2".repeat(64),
29-
threadRootId: "2".repeat(64),
30-
}),
31-
),
32-
).toBe("thread");
16+
expect(linkKind(`buzz://repo?owner=${"a".repeat(64)}&d=buzz`)).toBe("buzz");
3317
});
3418

3519
it.each([
@@ -63,6 +47,8 @@ it.each([
6347
"javascript:alert(1)",
6448
"data:text/html,hello",
6549
"buzz://unknown",
50+
// The retired in-app locator is an unknown host like any other.
51+
"buzz://open?target=%7B%22version%22%3A1%2C%22kind%22%3A%22home%22%7D",
6652
"not a URL",
6753
])("leaves unsupported destinations as plain text: %s", (href) => {
6854
expect(

‎src/features/conversation/MessageLink.tsx‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,7 @@ export function MessageLink({
7171
const trigger = useRef<HTMLAnchorElement>(null);
7272
const internal = isBuzzLink(url);
7373
const parsed = internal ? parseBuzzLink(url) : null;
74-
const destination =
75-
parsed?.format === "legacy"
76-
? parsed
77-
: parsed?.format === "shared" &&
78-
parsed.target.kind === "conversation" &&
79-
scope?.slice(0, -65) === parsed.target.scope.communityOrigin
80-
? parsed.target
81-
: undefined;
74+
const destination = parsed?.format === "legacy" ? parsed : undefined;
8275
const preview =
8376
session && destination?.messageId
8477
? { channelId: destination.channelId, messageId: destination.messageId }

‎src/features/messages/MessageMarkdown.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ function PreparedMessageMarkdown({
391391
? sourceRow
392392
: { ...sourceRow, content: prepared.content };
393393
const renderLink = (url: string, label?: string, children?: ReactNode) => {
394-
const channel = channelForLink(url, scope, directory.channels);
394+
const channel = channelForLink(url, directory.channels);
395395
return (
396396
<MessageLink
397397
url={url}
398-
label={label ?? channelLinkLabel(url, scope, directory.channels)}
398+
label={label ?? channelLinkLabel(url, directory.channels)}
399399
registry={extensions?.links}
400400
onOpenLink={onOpenLink}
401401
session={session}

‎src/features/messages/ReferenceText.tsx‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,23 @@ export function useReferenceDirectory(
5151
};
5252
}
5353

54+
/** Buzz links carry no community, so they always name a channel in the receiving one. */
5455
export function channelForLink(
5556
url: string,
56-
scope: string | undefined,
5757
channels: readonly ChannelSummary[],
5858
) {
5959
const parsed = parseBuzzLink(url);
60-
const target =
61-
parsed?.format === "legacy"
62-
? parsed
63-
: parsed?.format === "shared" &&
64-
parsed.target.kind === "conversation" &&
65-
parsed.target.scope.communityOrigin === scope?.slice(0, -65)
66-
? parsed.target
67-
: undefined;
60+
const target = parsed?.format === "legacy" ? parsed : undefined;
6861
return target && channels.find((item) => item.id === target.channelId);
6962
}
7063

7164
export function channelLinkLabel(
7265
url: string,
73-
scope: string | undefined,
7466
channels: readonly ChannelSummary[],
7567
) {
76-
const channel = channelForLink(url, scope, channels);
68+
const channel = channelForLink(url, channels);
7769
const parsed = parseBuzzLink(url);
78-
const target =
79-
parsed?.format === "legacy"
80-
? parsed
81-
: parsed?.format === "shared" && parsed.target.kind === "conversation"
82-
? parsed.target
83-
: undefined;
70+
const target = parsed?.format === "legacy" ? parsed : undefined;
8471
return channel
8572
? `${channel.channelType === "dm" || target?.messageId ? "" : "#"}${channel.name}`
8673
: undefined;

‎src/features/messages/message-copy.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export function messageCopyLink(
6363
...(row.threadRootId ? { threadRootId: row.threadRootId } : {}),
6464
});
6565
if (target.kind !== "conversation" || !target.messageId) return undefined;
66-
// Public Buzz links bind to the recipient's selected community. Scoped
67-
// buzz://open locators remain supported in-app, but cannot be shared to Buzz.
66+
// Buzz links carry no community or identity: they bind to the recipient's
67+
// selected community, so the sender's scope is deliberately left out.
6868
const params = new URLSearchParams({
6969
channel: target.channelId,
7070
id: target.messageId,

‎src/features/messages/message-link-parts.test.ts‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { expect, it } from "vitest";
22
import { messageLinkParts } from "./message-link-parts";
3-
import { targetLink } from "../navigation/targets";
43

5-
it("recognizes bare and wrapped Buzz channel, message, thread and shared links", () => {
4+
it("recognizes bare and wrapped Buzz channel, message and thread links", () => {
65
const urls = [
76
"buzz://channel/general",
87
`buzz://message?channel=general&id=${"a".repeat(64)}`,
98
`buzz://message?channel=general&id=${"a".repeat(64)}&thread=${"b".repeat(64)}`,
10-
targetLink({ version: 1, kind: "home" }),
119
];
1210
for (const url of urls) {
1311
for (const text of [url, `<${url}>`]) {
@@ -17,6 +15,38 @@ it("recognizes bare and wrapped Buzz channel, message, thread and shared links",
1715
}
1816
}
1917
});
18+
it("leaves the retired buzz://open locator as plain text, bare or wrapped", () => {
19+
const locator =
20+
"buzz://open?target=%7B%22version%22%3A1%2C%22kind%22%3A%22home%22%7D";
21+
for (const content of [
22+
`See ${locator}.`,
23+
`See <${locator}>.`,
24+
`See [home](${locator}).`,
25+
]) {
26+
const parts = messageLinkParts(content);
27+
expect(parts.some((part) => part.url)).toBe(false);
28+
expect(parts.map((part) => part.text).join("")).toBe(content);
29+
}
30+
});
31+
it("keeps Buzz links with unknown query parameters as links rather than plain text", () => {
32+
const url = `buzz://message?channel=general&id=${"a".repeat(64)}&foo=bar`;
33+
for (const text of [url, `<${url}>`, `[Reply](${url})`]) {
34+
const parts = messageLinkParts(`See ${text}.`);
35+
expect(parts.filter((part) => part.url).map((part) => part.url)).toEqual([
36+
url,
37+
]);
38+
}
39+
expect(
40+
messageLinkParts("See buzz://channel/general?relay=evil.").filter(
41+
(part) => part.url,
42+
),
43+
).toEqual([
44+
{
45+
text: "buzz://channel/general?relay=evil",
46+
url: "buzz://channel/general?relay=evil",
47+
},
48+
]);
49+
});
2050
it("does not turn malformed Buzz addresses into links", () => {
2151
const content = "<buzz://message?channel=general&id=bad>";
2252
expect(messageLinkParts(content).some((part) => part.url)).toBe(false);

0 commit comments

Comments
 (0)