Skip to content

Commit e833da7

Browse files
committed
fix(dashboard): open widget links through the Control UI external-url owner
The widget bridge opened links with a local window.open helper, which the lint:ui:no-raw-window-open boundary guard rejects. Delegate to openExternalUrlSafe(), the Control UI owner for external navigation: it applies noopener/noreferrer, detaches the opener handle, and keeps one canonical open path. The bridge keeps a narrower absolute-http(s) gate, since widget-supplied links must not reach blob: URLs that the shared external-link policy permits.
1 parent bda32f7 commit e833da7

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

‎ui/src/lib/board/widget-bridge.ts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isRecord } from "@openclaw/normalization-core/record-coerce";
22
import { dispatchWidgetPrompt } from "../../components/mcp-app-security.ts";
3+
import { openExternalUrlSafe } from "../open-external-url.ts";
34

45
type BoardWidgetBridgeRequest = {
56
type: "openclaw:widget-bridge-request";
@@ -21,7 +22,7 @@ const STATE_RATE_WINDOW_MS = 60_000;
2122
const STATE_RATE_MAX_ATTEMPTS = 12;
2223

2324
function openWidgetUrl(url: string): boolean {
24-
return window.open(url, "_blank", "noopener,noreferrer") !== null;
25+
return openExternalUrlSafe(url) !== null;
2526
}
2627

2728
export function isBoardWidgetBridgeRequest(value: unknown): value is BoardWidgetBridgeRequest {
@@ -144,18 +145,14 @@ export class BoardWidgetBridgeController {
144145
const params = assertWidgetRequestRecord(request.params);
145146
switch (request.method) {
146147
// Opening a link the user clicked is navigation, not a granted capability,
147-
// so this stays outside the tool-grant checks. The host owns the scheme
148-
// filter and always applies noopener/noreferrer, so a widget cannot reach
149-
// another scheme or retain a handle by omitting `rel` in its own markup.
148+
// so this stays outside the tool-grant checks. Opening goes through the
149+
// Control UI's openExternalUrlSafe owner, which applies noopener/noreferrer
150+
// regardless of the `rel` a widget wrote. The absolute-http(s) gate here is
151+
// deliberately narrower than that shared policy: widget-supplied links must
152+
// not reach `blob:`, which the general external-link path allows.
150153
case "host.open": {
151154
const url = requiredString(params, "url");
152-
let parsed: URL;
153-
try {
154-
parsed = new URL(url);
155-
} catch {
156-
throw new Error("widget link url is invalid");
157-
}
158-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
155+
if (!/^https?:\/\//i.test(url)) {
159156
throw new Error("widget link url is invalid");
160157
}
161158
if (!this.openUrl(url)) {

0 commit comments

Comments
 (0)