From 7e42efc48e59073ff6a8bb8da10337ba0a36052d Mon Sep 17 00:00:00 2001 From: wangdequan Date: Mon, 8 Jun 2026 09:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E8=A7=84=E5=88=92=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:将 INI 派生非法参数文件和刀具表文件名的拒绝验证扩展到真实 Chromium OPFS 与 LinuxCNC INI WASM 路径,并通过 host/WASM/browser 聚合验证。 --- wasm-port/docs/compatibility-validation.md | 10 ++-- wasm-port/tests/browser/interp_smoke.html | 58 ++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/wasm-port/docs/compatibility-validation.md b/wasm-port/docs/compatibility-validation.md index d9bb4b6..159e9c8 100644 --- a/wasm-port/docs/compatibility-validation.md +++ b/wasm-port/docs/compatibility-validation.md @@ -123,7 +123,9 @@ named-parameter file path and negative interpreter fixtures with expected error text plus absent canonical motion output. It also uses real browser OPFS storage plus the interpreter SDK to restore and save a LinuxCNC parameter file through vendored `Interp::restore_parameters()` and `Interp::save_parameters()`, -and to load/save LinuxCNC tool tables through vendored `tooldata_common.cc`. +to load/save LinuxCNC tool tables through vendored `tooldata_common.cc`, and +to reject invalid INI-derived parameter/tool-table file names through the OPFS +path model after the names are parsed by the LinuxCNC-backed INI WASM SDK. The aggregate host smoke script builds the INI and interpreter-core WASM artifacts once, then runs the Node WASM smokes, the Node OPFS mock smoke, and @@ -260,9 +262,9 @@ groups INI, parameter, and tool-table loading, the random-toolchanger flag derived from vendored LinuxCNC INI boolean parsing, INI-derived `[RS274NGC]PARAMETER_FILE` and `[EMCIO]TOOL_TABLE` file names mapped to OPFS machine files, OPFS path-model rejection of invalid INI-derived file names, -and a browser interpreter smoke that uses the same session bridge before -saving OPFS-backed parameter and tool-table text through vendored LinuxCNC -file APIs. +and a browser interpreter smoke that uses the same session bridge with real +LinuxCNC INI WASM parsing before saving OPFS-backed parameter and tool-table +text through vendored LinuxCNC file APIs. Full browser coverage, full SDK coverage, and richer machine-state validation remain future work. diff --git a/wasm-port/tests/browser/interp_smoke.html b/wasm-port/tests/browser/interp_smoke.html index 4b9b81e..ff27744 100644 --- a/wasm-port/tests/browser/interp_smoke.html +++ b/wasm-port/tests/browser/interp_smoke.html @@ -61,6 +61,18 @@ } } + async function verifyRejects(fixtureName, operation, expectedPattern) { + try { + await operation(); + } catch (error) { + if (!expectedPattern.test(error.message)) { + throw new Error(`${fixtureName}: unexpected error ${error.message}`); + } + return; + } + throw new Error(`${fixtureName}: expected rejection`); + } + try { const interp = await createLinuxCncInterpSdk({ locateFile(path) { @@ -400,6 +412,52 @@ ].join("\n"), ); + await saveMachineTextFiles("browser-invalid-param-file-session", { + ini: [ + "[EMC]", + "MACHINE = browser-invalid-param-file-session", + "", + "[RS274NGC]", + "PARAMETER_FILE = ../escape.var", + "", + ].join("\n"), + }); + await verifyRejects( + "opfs_reject_invalid_ini_parameter_file", + () => loadMachineSessionFromOpfs( + interp, + "browser-invalid-param-file-session", + { + iniSdk: ini, + iniWasmPath: "/work/browser-invalid-param-file-session.ini", + }, + ), + /Invalid parameter filename/, + ); + + await saveMachineTextFiles("browser-invalid-tool-file-session", { + ini: [ + "[EMC]", + "MACHINE = browser-invalid-tool-file-session", + "", + "[EMCIO]", + "TOOL_TABLE = nested/tool.tbl", + "", + ].join("\n"), + }); + await verifyRejects( + "opfs_reject_invalid_ini_tool_table", + () => loadMachineSessionFromOpfs( + interp, + "browser-invalid-tool-file-session", + { + iniSdk: ini, + iniWasmPath: "/work/browser-invalid-tool-file-session.ini", + }, + ), + /Invalid tool table filename/, + ); + status.textContent = "browser_interp_smoke=ok"; } catch (error) { status.textContent = `browser_interp_smoke=fail ${error.stack || error.message}`;