openclaw - ✅(Solved) Fix Remote media URL fallback filenames keep percent escapes [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#84050Fetched 2026-05-20 03:44:45
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
1
Author
Timeline (top)
labeled ×7cross-referenced ×2closed ×1commented ×1

Remote media fetched from an HTTP URL can surface a percent-encoded URL path basename as the filename when there is no Content-Disposition filename or caller filePathHint.

For example, a URL like:

https://example.com/files/My%20Report.pdf

is exposed as:

My%20Report.pdf

instead of:

My Report.pdf

Root Cause

Remote media fetched from an HTTP URL can surface a percent-encoded URL path basename as the filename when there is no Content-Disposition filename or caller filePathHint.

For example, a URL like:

https://example.com/files/My%20Report.pdf

is exposed as:

My%20Report.pdf

instead of:

My Report.pdf

Fix Action

Fixed

PR fix notes

PR #84052: fix(media): decode remote URL fallback filenames

Description (problem / solution / changelog)

Summary

  • Decode valid percent escapes in URL path basenames before using them as remote media fallback filenames.
  • Preserve decoded %2F and %5C segment identity by replacing decoded separators with safe filename underscores.
  • Keep malformed percent-escaped basenames as raw text instead of throwing.
  • Add focused saveRemoteMedia regression coverage and an Unreleased changelog entry.

Fixes #84050.

Real behavior proof

Behavior or issue addressed: Remote media fetched from a URL such as /files/My%20Report.pdf should expose My Report.pdf as the fallback filename when the response has no Content-Disposition filename.

Real environment tested: OpenClaw source checkout at f93dca627a8201e212d6cda867815e657bada005 on macOS with Node.js 24.11.1. The run used an isolated OPENCLAW_STATE_DIR and a local HTTP server serving the PDF bytes through the real saveRemoteMedia source-runtime path.

Exact steps or command run after this patch:

node --import tsx /private/tmp/openclaw-84052-proof.mjs

Evidence after fix: Copied console output from the after-fix run:

{
  "setup": "local HTTP server + real saveRemoteMedia source runtime",
  "url": "http://127.0.0.1:63237/files/My%20Report.pdf",
  "fileName": "My Report.pdf",
  "contentType": "application/pdf",
  "size": 21,
  "storedPathBasename": "25319a44-8c4e-4e74-b0fb-b02f6904b821.pdf",
  "storedBytesMatch": true,
  "stateDir": "/var/folders/qg/ftvdj43s1b79kv3g92r9yzsm0000gn/T/openclaw-84052-proof-1ncWQT"
}

Observed result after fix: The real runtime fetch completed, returned fileName: "My Report.pdf" instead of My%20Report.pdf, stored the PDF as application/pdf, and confirmed storedBytesMatch: true.

What was not tested: none.

Tests

  • node scripts/test-projects.mjs src/media/fetch.test.ts
  • pnpm exec oxfmt --check --threads=1 src/media/fetch.ts src/media/fetch.test.ts
  • git diff --check origin/main...HEAD
  • git merge-tree --write-tree HEAD origin/main

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/media/fetch.test.ts (modified, +63/-0)
  • src/media/fetch.ts (modified, +13/-1)

PR #84108: fix(media): decode remote URL fallback filenames

Description (problem / solution / changelog)

Makes https://github.com/openclaw/openclaw/pull/84052 merge-ready for the ClawSweeper automerge loop. The edit pass should inspect the live PR diff, review comments, and failing checks; rebase if needed; keep the contributor branch credited; and stop only when validation is green or an external blocker is proven. Known failing checks:

ClawSweeper 🐠 replacement reef notes:

<!-- clawsweeper-automerge-requested-by login="Takhoffman" id="781889" -->
  • Repair fallback: GitHub rejected the repair branch push because it updates workflow files and the ClawSweeper app token does not have workflows permission

Inherited issue-closing references from the source PR: Fixes #84050

Co-author credit kept:

fish notes: model gpt-5.5, reasoning high; reviewed against 8cbac43f9bbd.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/media/fetch.test.ts (modified, +64/-0)
  • src/media/fetch.ts (modified, +13/-1)

Code Example

https://example.com/files/My%20Report.pdf

---

My%20Report.pdf

---

My Report.pdf

---

new URL("https://example.com/files/My%20Report.pdf").pathname
RAW_BUFFERClick to expand / collapse

Bug type

Bug

Summary

Remote media fetched from an HTTP URL can surface a percent-encoded URL path basename as the filename when there is no Content-Disposition filename or caller filePathHint.

For example, a URL like:

https://example.com/files/My%20Report.pdf

is exposed as:

My%20Report.pdf

instead of:

My Report.pdf

Steps to reproduce

On current main, the URL fallback in src/media/fetch.ts parses finalUrl, reads parsed.pathname, and passes that pathname directly to basenameFromAnyPath.

URL.pathname preserves percent escapes, so the fallback filename remains encoded:

new URL("https://example.com/files/My%20Report.pdf").pathname

returns /files/My%20Report.pdf, and the saved/read media filename becomes My%20Report.pdf.

Expected behavior

The URL path basename fallback should decode valid percent escapes before exposing the filename, so ordinary URL-safe filenames such as My%20Report.pdf become My Report.pdf.

Actual behavior

The raw encoded path basename is exposed as the media filename.

Impact

Agents and chat integrations that rely on OpenClaw's remote media filename fallback can show or forward URL-encoded filenames to users. This is visible whenever the remote response lacks a filename-bearing Content-Disposition header and the caller does not provide a filename hint.

Duplicate check

I searched current open issues and PRs for:

  • remote media filename
  • remote URL filename
  • URL filename percent encoded
  • percent-encoded filename
  • src/media/fetch.ts filename

I found related closed Feishu/local-file filename issues such as #44988, #43840, and #31179, plus closed Feishu PRs such as #43916, #43860, and #43983. Those cover Feishu upload/download/local-file filename handling; I did not find an open issue or PR for the generic remote media URL fallback in src/media/fetch.ts.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The URL path basename fallback should decode valid percent escapes before exposing the filename, so ordinary URL-safe filenames such as My%20Report.pdf become My Report.pdf.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Remote media URL fallback filenames keep percent escapes [2 pull requests, 1 comments, 2 participants]