From 2d663152efaf8c8ad3c58e53f6c7dfe00413d46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Sun, 22 Nov 2026 12:44:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=AA=A2=E6=9F=A5=E8=A3=9C?= =?UTF-8?q?=E5=85=A9=E5=80=8B=E9=98=B2=E8=AD=B7=EF=BC=9A=E5=9C=96=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=AA=A2=E6=9F=A5=E4=B9=9F=E6=93=8B=E6=8F=9B=E8=A1=8C?= =?UTF-8?q?=E3=80=81Tab=E3=80=81=E6=96=9C=E7=B7=9A=E6=88=96=E5=BC=95?= =?UTF-8?q?=E8=99=9F=E5=BE=8C=E9=9D=A2=E6=8E=A5=E7=9A=84=20on=E2=80=A6=3D?= =?UTF-8?q?=20=E5=B1=AC=E6=80=A7=EF=BC=88=E5=8A=A0=E6=B8=AC=E8=A9=A6?= =?UTF-8?q?=EF=BC=89=EF=BC=9B=E6=89=8B=E6=A9=9F=E6=8B=96=E6=9B=B3=20Mac=20?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=91=E6=9C=80=E5=A4=9A=20200=20=E5=80=8B?= =?UTF-8?q?=E9=BB=9E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已驗證: cargo test 884 個全過(含新測試 a_drawn_chart_runs_nothing),clippy 沒有新警告。 未驗證: 手機實際拖曳 Mac(要實機 Mac 和手機,會動到使用者正在用的螢幕)。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm --- src/remote.rs | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/remote.rs b/src/remote.rs index 0c44252..7c0f1e2 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -1333,11 +1333,12 @@ fn svg_is_plain(svg: &str) -> bool { if l.contains(" Resp { "click" => ("computer_use_click", json!({"x": x, "y": y, "button": v["button"].as_str().unwrap_or("left"), "count": v["count"].as_u64().unwrap_or(1).clamp(1, 3), "modifier_keys": mods(v)})), // 虛擬觸控板: the pointer moves (no click), and a drag goes along the finger's path. "move" => ("computer_use_mouse_move", json!({"x": x, "y": y})), - "drag" => ("computer_use_drag", json!({"path": v["path"], "modifier_keys": mods(v)})), + // (A finger's path is a few dozen points; a longer one is cut, not walked for minutes.) + "drag" => ("computer_use_drag", json!({"path": v["path"].as_array().map(|a| a.iter().take(MAX_DRAG_POINTS).cloned().collect::>()).unwrap_or_default(), "modifier_keys": mods(v)})), "type" => ("computer_use_typing", json!({"value": v["text"]})), // (A combination too: "cmd+tab", from the key bar.) "key" => ("computer_use_press_key", json!({"key": v["key"]})), @@ -3696,6 +3701,24 @@ mod tests { use super::*; + /// A chart goes to the phone only as shapes and words: whatever a bot (or a page it read) + /// writes in a diagram's labels, links and styles, nothing in the drawing can run. + #[test] + fn a_drawn_chart_runs_nothing() { + for bad in ["", "", "", "", "", "", "", ""] { + assert!(!svg_is_plain(bad), "{bad}"); + } + for fine in ["turn on = yes, onward", "", "conclusion=1"] { + assert!(svg_is_plain(fine), "{fine}"); + } + for src in ["graph TD\n A[\"\"] --> B[\"\"]", "graph TD\n A --> B\n click A href \"javascript:alert(1)\"", "graph TD\n A[\"x\\\" onload=\\\"alert(1)\"] --> B"] { + if let Ok(svg) = crate::diagram::svg(src, false) { + let l = svg.to_ascii_lowercase(); + assert!(!svg_is_plain(&svg) || (!l.contains("