Image/file loader has issues when file uri contains escaped spaces.
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 67
Description
**Describe the bug**
For `file://` URIs to images, if there is a URI-escaped space (or perhaps other charactter, I haven't checked), it will cause issues finding and loading the image/file (at least on Windows 11). I suspect this is due to this function:
https://github.com/emilk/egui/blob/68b74530b7848cef6bff4efc5fc9906bfbd1e8ca/crates/egui_extras/src/loaders/file_loader.rs#L32
which does not handle `file://` URIs as actual URIs with escaping, and instead just strips the prefix.
Here's the log message with a file path, showing a `%20` representing a space in my username.
```
[desktop\src\view\search\col_format.rs:22:35] uri.as_str() = "file:///C:/Users/alfri/AppData/Local/Venus%20Xeon-Blonde/Oshibana/cache/symbology-cache/U.svg"
```
**Screenshots**
With initial code:
```rust
ui.image(uri.as_str());
```
With workaround:
```rust
match uri.to_file_path() {
Ok(path) => {
let reformatted = if cfg!(windows) {
format!("file:///{}", path.display())
} else {
format!("file://{}", path.display())
};
ui.image(reformatted);
},
Err(_) => {
ui.image(uri.as_str());
},
};
```
**Desktop (please complete the following information):**
- OS: Windows 11
Contributor guide
Research direction
Start in crates/egui_extras/src/loaders/file_loader.rs at the linked line and reproduce loading a Windows file:// URI containing an escaped space such as %20. Confirm the loader resolves the URI to the intended file path and that the image loads successfully instead of failing to find the file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100