Repository navigation
fix: resolve chromium-rewritten assets:// urls - #13321
tiensonqin wants to merge 3 commits into
Conversation
Chromium treats the privileged assets scheme as a standard URL, so assets:///home/... is rewritten to assets://home/... (host=home). Reconstruct the filesystem path from host + pathname. Co-authored-by: Tienson Qin <[email protected]>
The colon-protected drive rewrite now lives in assets-url resolution. Co-authored-by: Tienson Qin <[email protected]>
A single-letter host is only a rewritten Windows drive when the pathname carries the /logseq__colon/ drive marker; otherwise on win32 it remains a UNC server name, matching the previous handler's assumption. Also merge the two identical path-prefix branches and cover the single-letter UNC and js/URL-fallback cases. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
9b686e4 to
4dba3a3
Compare
| ;; Chromium standard-scheme rewrite: assets:///home/foo → assets://home/foo | ||
| :else | ||
| (str "/" host pathname)))) |
There was a problem hiding this comment.
🔴 Capitalized root directories become lowercase
When Chromium rewrites /Users/..., assets-url->fs-path reconstructs /users/... from the canonicalized host. Assets under that case-sensitive root fail to load.
Learn more
Chromium treats this registered standard scheme's first path segment as an authority. Authority canonicalization lowercases ASCII host names before the protocol callback receives the URL, so reconstructing the path from host cannot recover the original casing. The frontend currently emits local paths as three-slash assets URLs in resolve-asset-real-path-url and <make-asset-url.
Example: A graph asset at /Users/Alice/graph/assets/photo.png becomes a request with host users. The handler returns /users/Alice/graph/assets/photo.png, which does not exist on a case-sensitive filesystem.
Recommended fix: Keep filesystem path components out of the authority. Emit assets URLs with a fixed sentinel host and place the complete encoded absolute path in pathname, then teach assets-url->fs-path to remove that sentinel. Update every assets URL producer and add a capitalized-root integration case.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Closing as a duplicate of #13898, which covers the same bug more completely. Thanks! |
Fixes logseq/db-test#1231
Problem
Adding an asset on Linux Desktop logs:
The assets scheme is registered as a Chromium standard scheme. Chromium therefore rewrites
assets:///home/...toassets://home/..., treating the first path segment as the host. The protocol handler strippedassets://and required the remainder to start with/, so the rewritten URL was rejected.Change
Extract
electron.assets-url/assets-url->fs-pathand reconstruct the filesystem path from URL host + pathname:assets://home/user/file.jpg→/home/user/file.jpgassets:///home/user/file.jpg→/home/user/file.jpgassets://C/logseq__colon/Users/...→/C:/Users/...assets://server/share/file.jpg→//server/share/file.jpgThe unused
decode-protected-assets-schema-pathhelper is removed; colon decoding now happens after reconstruction.A single-letter host only counts as a rewritten Windows drive when the pathname carries the
/logseq__colon/marker; otherwise on win32 it is still treated as a UNC server (assets://s/share→//s/share), matching the previous handler's assumption.Tests
Adds focused unit coverage in
electron.assets-url-testfor the three-slash form, Chromium host form, query/fragment stripping, Windows drive (including rewritten host form), UNC (including single-letter hosts), and thejs/URLparse-failure fallback.Link to Devin session: https://app.devin.ai/sessions/f20af14345034f62a799def20dda7895
Open in Devin Desktop: https://app.devin.ai/desktop/session/f20af14345034f62a799def20dda7895?variant=devin
Requested by: @tiensonqin