From d352150ad1492fa362ebe3f1c7336345bdf67774 Mon Sep 17 00:00:00 2001 From: Apageoflove Date: Wed, 18 Nov 2026 04:42:05 -0500 Subject: [PATCH] =?UTF-8?q?fix(minimax-bot):=20=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E5=B8=A6=20..=20=E7=9A=84=E4=B8=8A=E4=BC=A0=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E6=B0=B8=E4=B9=85=E9=99=84=E5=8A=A0=E4=B8=8D=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit safeUploadName 只替换了少数禁用字符,于是 report..final.txt 这类名字原样 成为上传 id 的一部分;而 engine 的 resolveAttachments 明确拒绝含 .. 的 id, 这份附件从此永远附加不上,消息发送失败但上传本身看起来是成功的。 两处收紧:连续的点替换成一个下划线(单个点保留,扩展名不受影响), 超长名字按码位而不是 UTF-16 单元切开,避免把 emoji 劈成孤立代理。 新测试走真实 /api/uploads,断言返回的 id 不含 .. 且能通过 UPLOAD_NAME_RE, 普通文件名保持原样。在 0.7.28 上红、在切片上绿。全量 414 条通过。 --- .../minimax-bot/.minimax-plugin/plugin.json | 2 +- plugins/minimax-ai/minimax-bot/README.md | 5 +++++ .../minimax-bot/miniapp/node/mcp.mjs | 2 +- .../minimax-bot/miniapp/node/server.mjs | 10 +++++++++- plugins/minimax-ai/minimax-bot/package.json | 2 +- .../tests/http-reliability.test.mjs | 18 ++++++++++++++++++ 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json index 7e5cc956..c98f2705 100644 --- a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json +++ b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "minimax-bot", "displayName": "MiniMax Bot", - "version": "0.7.32", + "version": "0.7.35", "description": "Turn MiniMax Code into an always-on team of Bots. A Chief Bot helps you build the team; in group chats the admin answers and @mentions hand work to other members. Every Bot has its own octopus avatar and memory, with scheduled tasks and usage stats.", "author": "MiniMax Code", "icon": "icon.png", diff --git a/plugins/minimax-ai/minimax-bot/README.md b/plugins/minimax-ai/minimax-bot/README.md index dcaf8d60..6dd1733f 100644 --- a/plugins/minimax-ai/minimax-bot/README.md +++ b/plugins/minimax-ai/minimax-bot/README.md @@ -116,6 +116,11 @@ The hand-over between two Bots of a group carried the tail of the previous reply - Two writes the plugin fires and forgets had nothing to catch their failure: the session id recorded when a turn starts, and the scheduled-task scan that runs every 30 seconds. A failed write there became an unhandled rejection, and the Host fails the whole Mini App process on one of those — so a disk that would not take a write took every running turn with it, and the scheduled task kept retrying every 30 seconds. - Both now report the failure through the plugin log, the way the task save next to one of them already did. The turn carries on, and the scan keeps running. +## 0.7.35 An uploaded file whose name carries `..` can be attached + +- An upload kept the file name as given apart from a few forbidden characters, so a name containing `..` reached the stored id. The attachment reader refuses any id with `..` in it, and the file could never be attached again — the upload looked fine and the message that tried to use it failed. +- The stored name now replaces a run of dots, and a long name is cut on a whole character so an emoji is never left half-written. + ## 0.7.10 Optional group notes - A group can keep a note of what it said. After every round the group records the closing lines of the replies, and every Bot of the group gets that record in its standing brief. diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs index f6c660f0..bdc9f9e4 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs @@ -662,7 +662,7 @@ export function createMcpHandler({ team, engine }) { result = { protocolVersion: PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSIONS[0], capabilities: { tools: { listChanged: false } }, - serverInfo: { name: 'minimax-bot', version: '0.7.32' }, + serverInfo: { name: 'minimax-bot', version: '0.7.35' }, instructions: t('mcp.instructions'), }; break; diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/server.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/server.mjs index 4ec12d19..eaa6ec1f 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/server.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/server.mjs @@ -95,7 +95,15 @@ const MAX_UPLOAD_BYTES = 50 * 1024 * 1024; /** A file name safe to keep on disk and show back: no path parts, controls or leading dots. */ function safeUploadName(raw) { const base = String(raw ?? '').split(/[\\/]/).pop() ?? ''; - const clean = base.replace(/[\u0000-\u001f\u007f<>:"|?*]/g, '_').replace(/^\.+/, '').trim().slice(0, 140); + // `..` reaches the stored id, and the attachment reader refuses any id carrying it, so the file + // could never be attached again. Cut by code point so a character such as an emoji is not left + // half-written, but stay inside the id's own byte-length budget. + const points = [...base.replace(/[\u0000-\u001f\u007f<>:"|?*]/g, '_').replace(/\.{2,}/g, '_').replace(/^\.+/, '').trim()]; + let clean = ''; + for (const point of points) { + if (clean.length + point.length > 140) break; + clean += point; + } return clean || 'file'; } diff --git a/plugins/minimax-ai/minimax-bot/package.json b/plugins/minimax-ai/minimax-bot/package.json index acc9773b..a34e286d 100644 --- a/plugins/minimax-ai/minimax-bot/package.json +++ b/plugins/minimax-ai/minimax-bot/package.json @@ -1,6 +1,6 @@ { "name": "minimax-bot", - "version": "0.7.32", + "version": "0.7.35", "private": true, "type": "module", "mcode": { diff --git a/plugins/minimax-ai/minimax-bot/tests/http-reliability.test.mjs b/plugins/minimax-ai/minimax-bot/tests/http-reliability.test.mjs index 1ec19828..ca250173 100644 --- a/plugins/minimax-ai/minimax-bot/tests/http-reliability.test.mjs +++ b/plugins/minimax-ai/minimax-bot/tests/http-reliability.test.mjs @@ -10,6 +10,7 @@ import { pathToFileURL } from 'node:url'; const pluginRoot = resolve(process.env.BOT_PLUGIN_ROOT ?? resolve(import.meta.dirname, '..')); const { start } = await import(pathToFileURL(join(pluginRoot, 'miniapp/node/server.mjs')).href); const { Store } = await import(pathToFileURL(join(pluginRoot, 'miniapp/node/store.mjs')).href); +const { UPLOAD_NAME_RE } = await import(pathToFileURL(join(pluginRoot, 'miniapp/node/engine.mjs')).href); async function fixture(t, { messages = 0, prepare, agent } = {}) { const dataDir = await mkdtemp(join(tmpdir(), 'bot-http-reliability-')); @@ -359,3 +360,20 @@ test('HTTP task snapshot and stop endpoint control an admitted MCP delegation', for(let i=0;i<100;i++){ status=(await (await fetch(`${base}/api/state`)).json()).tasks[0].status;if(status==='cancelled')break;await new Promise((resolve)=>setTimeout(resolve,5)); } assert.equal(status,'cancelled'); }); + +test('an upload whose name carries .. still produces an id the attachment reader accepts', async (t) => { + const { base } = await fixture(t); + // The attachment reader refuses any id containing `..`, so the stored name must not carry it. + const response = await fetch(`${base}/api/uploads?name=${encodeURIComponent('report..final.txt')}`, { + method: 'POST', body: 'hello', headers: { 'content-type': 'application/octet-stream' }, + }); + const body = await response.json(); + assert.equal(response.status, 200); + assert.equal(body.upload.id.includes('..'), false, body.upload.id); + assert.equal(UPLOAD_NAME_RE.test(body.upload.id), true, body.upload.id); + // A normal name is left alone. + const plain = await fetch(`${base}/api/uploads?name=notes.txt`, { + method: 'POST', body: 'hello', headers: { 'content-type': 'application/octet-stream' }, + }); + assert.equal((await plain.json()).upload.name, 'notes.txt'); +});