Skip to content

Commit 5d19030

Browse files
author
Ishan Godawatta
committed
fix: allow custom control UI origins
1 parent f256eeb commit 5d19030

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Docs: https://docs.openclaw.ai
1818
- Active Memory docs: document the `cacheTtlMs` 1000-120000 ms range and 15000 ms default so setup snippets do not lead users past the schema limit. Fixes #65708. (#65737) Thanks @WuKongAI-CMU.
1919
- fix(agents): canonicalize provider aliases in byProvider tool policy lookup [AI]. (#72917) Thanks @pgondhi987.
2020
- fix(security): block npm_execpath injection from workspace .env [AI-assisted]. (#73262) Thanks @pgondhi987.
21+
- Gateway/Control UI: match custom-scheme browser origins such as `tauri://localhost` against explicit `gateway.controlUi.allowedOrigins` entries, so desktop wrappers do not need wildcard origins. Fixes #46520. Thanks @mosidevv.
2122
- Tools/web_fetch: decode response bodies from raw bytes using declared HTTP, XML, or HTML meta charsets before extraction, so Shift_JIS and other legacy-charset pages no longer return mojibake. Fixes #72916. Thanks @amknight.
2223
- Active Memory: skip payload-less `memory_search` transcript tool results when building debug telemetry, so newer empty entries no longer hide the latest useful debug payload. (#68773) Thanks @SimbaKingjoe.
2324
- Channels/Discord: bound message read/search REST calls, route those actions through Gateway execution, and fall back to `CommandTargetSessionKey` for inbound hook session keys so Discord reads do not hang and hooks still fire when `SessionKey` is empty. Fixes #73431. (#73521) Thanks @amknight.

src/gateway/origin-check.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ describe("checkBrowserOrigin", () => {
5656
},
5757
expected: { ok: true as const, matchedBy: "allowlist" as const },
5858
},
59+
{
60+
name: "accepts allowlisted custom-scheme origins",
61+
input: {
62+
requestHost: "gateway.example.com:18789",
63+
origin: "tauri://LOCALHOST",
64+
allowedOrigins: ["tauri://localhost"],
65+
},
66+
expected: { ok: true as const, matchedBy: "allowlist" as const },
67+
},
68+
{
69+
name: "rejects unlisted custom-scheme origins",
70+
input: {
71+
requestHost: "gateway.example.com:18789",
72+
origin: "electron://localhost",
73+
allowedOrigins: ["tauri://localhost"],
74+
},
75+
expected: { ok: false as const, reason: "origin not allowed" },
76+
},
5977
{
6078
name: "rejects missing origin",
6179
input: {

src/gateway/origin-check.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ function parseOrigin(
2020
}
2121
try {
2222
const url = new URL(trimmed);
23+
const origin =
24+
url.origin === "null" && url.protocol && url.host
25+
? `${url.protocol}//${url.host}`
26+
: url.origin;
2327
return {
24-
origin: normalizeLowercaseStringOrEmpty(url.origin),
28+
origin: normalizeLowercaseStringOrEmpty(origin),
2529
host: normalizeLowercaseStringOrEmpty(url.host),
2630
hostname: normalizeLowercaseStringOrEmpty(url.hostname),
2731
};

0 commit comments

Comments
 (0)