fix(media): trim json suffixes from media paths · openclaw/openclaw@25ca2fc
steipete
·
2026-05-02
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,7 @@ Docs: https://docs.openclaw.ai
|
22 | 22 | ### Fixes |
23 | 23 | |
24 | 24 | - Gateway/chat history: merge Claude CLI transcript imports for Anthropic-routed sessions that still have a Claude CLI binding, so local chat history does not hide CLI JSONL turns. Fixes #75850. Thanks @alfredjbclaw. |
| 25 | +- Media: trim serialized JSON suffixes after local `MEDIA:` directive file extensions, so generated-image metadata cannot pollute the parsed media path and cause false `ENOENT` delivery failures. Fixes #75182. Thanks @TnzGit and @hclsys. |
25 | 26 | - Cron: make scheduler reload schedule comparison tolerate malformed persisted jobs, so one bad cron entry no longer aborts the whole tick. Fixes #75886. Thanks @samfox-ai. |
26 | 27 | - Doctor/channels: warn after migrations when default Telegram or Discord accounts have no configured token and their env fallback (`TELEGRAM_BOT_TOKEN` or `DISCORD_BOT_TOKEN`) is unavailable, with secret-safe migration docs for checking state-dir `.env`. Fixes #74298. Thanks @lolaopenclaw. |
27 | 28 | - Control UI/chat: keep live replies visible when a raw session alias such as `main` sends the chat turn but Gateway emits events under the canonical session key for the same run. Fixes #73716. Thanks @teebes. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -54,6 +54,15 @@ describe("splitMediaFromOutput", () => {
|
54 | 54 | ["C:\\Users\\pete\\Pictures\\snap.png", "MEDIA:C:\\Users\\pete\\Pictures\\snap.png"], |
55 | 55 | ["/tmp/tts-fAJy8C/voice-1770246885083.opus", "MEDIA:/tmp/tts-fAJy8C/voice-1770246885083.opus"], |
56 | 56 | ["image.png", "MEDIA:image.png"], |
| 57 | +[ |
| 58 | +"/path/to/image.png", |
| 59 | +'MEDIA:/path/to/image.png"}],"details":{"provider":"openai","model":"gpt-image-2"}', |
| 60 | +], |
| 61 | +[ |
| 62 | +"/path/to/image.png", |
| 63 | +String.raw`MEDIA:/path/to/image.png\"}],\"details\":{\"provider\":\"openai\"}`, |
| 64 | +], |
| 65 | +["/tmp/render,final.png", "MEDIA:/tmp/render,final.png"], |
57 | 66 | ] as const)("accepts supported media path variant: %s", (expectedPath, input) => { |
58 | 67 | expectAcceptedMediaPathCase(expectedPath, input); |
59 | 68 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,8 +34,12 @@ export function normalizeMediaSource(src: string) {
|
34 | 34 | return src.startsWith("file://") ? src.replace("file://", "") : src; |
35 | 35 | } |
36 | 36 | |
| 37 | +const TRAILING_SERIALIZED_JSON_AFTER_EXT_RE = /^(.*\.\w{1,10})\\?"(?=[\]},:,]|$).*/s; |
| 38 | + |
37 | 39 | function cleanCandidate(raw: string) { |
38 | | -return raw.replace(/^[`"'[{(]+/, "").replace(/[`"'\\})\],]+$/, ""); |
| 40 | +const stripped = raw.replace(/^[`"'[{(]+/, "").replace(/[`"'\\})\],]+$/, ""); |
| 41 | +const jsonSuffixMatch = TRAILING_SERIALIZED_JSON_AFTER_EXT_RE.exec(stripped); |
| 42 | +return jsonSuffixMatch?.[1] ?? stripped; |
39 | 43 | } |
40 | 44 | |
41 | 45 | const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。