惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
B
Blog
博客园_首页
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
罗磊的独立博客
Jina AI
Jina AI
C
Check Point Blog
Martin Fowler
Martin Fowler
J
Java Code Geeks
博客园 - 司徒正美
美团技术团队
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
小众软件
小众软件

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(browser): reject invalid tab indexes · openclaw/openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
1+

import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";

12

import { resolveBrowserNavigationProxyMode } from "../browser-proxy-mode.js";

23

import {

34

BrowserProfileUnavailableError,

@@ -12,13 +13,7 @@ import {

1213

import type { BrowserRouteContext, ProfileContext } from "../server-context.js";

1314

import { resolveTargetIdFromTabs } from "../target-id.js";

1415

import type { BrowserRequest, BrowserResponse, BrowserRouteRegistrar } from "./types.js";

15-

import {

16-

asyncBrowserRoute,

17-

getProfileContext,

18-

jsonError,

19-

toNumber,

20-

toStringOrEmpty,

21-

} from "./utils.js";

16+

import { asyncBrowserRoute, getProfileContext, jsonError, toStringOrEmpty } from "./utils.js";

22172318

function resolveTabsProfileContext(

2419

req: BrowserRequest,

@@ -136,6 +131,27 @@ function readOptionalTabLabel(body: unknown): string | undefined {

136131

return label || undefined;

137132

}

138133134+

function readTabIndex(

135+

res: BrowserResponse,

136+

body: unknown,

137+

opts?: { required?: boolean },

138+

): number | null | undefined {

139+

const record = body && typeof body === "object" ? (body as Record<string, unknown>) : {};

140+

if (!Object.hasOwn(record, "index")) {

141+

if (opts?.required) {

142+

jsonError(res, 400, "index is required");

143+

return null;

144+

}

145+

return undefined;

146+

}

147+

const index = parseStrictNonNegativeInteger(record.index);

148+

if (index === undefined) {

149+

jsonError(res, 400, "index must be a non-negative integer");

150+

return null;

151+

}

152+

return index;

153+

}

154+139155

async function runTabTargetMutation(params: {

140156

req: BrowserRequest;

141157

res: BrowserResponse;

@@ -269,7 +285,6 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

269285

"/tabs/action",

270286

asyncBrowserRoute(async (req, res) => {

271287

const action = toStringOrEmpty((req.body as { action?: unknown })?.action);

272-

const index = toNumber((req.body as { index?: unknown })?.index);

273288274289

await withTabsProfileRoute({

275290

req,

@@ -320,6 +335,10 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

320335

if (!(await ensureBrowserRunning(profileCtx, res))) {

321336

return;

322337

}

338+

const index = readTabIndex(res, req.body);

339+

if (index === null) {

340+

return;

341+

}

323342

const tabs = await profileCtx.listTabs();

324343

const target = resolveIndexedTab(tabs, index);

325344

if (!target) {

@@ -330,8 +349,9 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

330349

}

331350332351

if (action === "select") {

333-

if (typeof index !== "number") {

334-

return jsonError(res, 400, "index is required");

352+

const index = readTabIndex(res, req.body, { required: true });

353+

if (index === null || index === undefined) {

354+

return;

335355

}

336356

if (!(await ensureBrowserRunning(profileCtx, res))) {

337357

return;