fix(uri): preserve percent escapes in plain local paths - #4303
Open
AndreyGatsuk wants to merge 1 commit into
Open
fix(uri): preserve percent escapes in plain local paths#4303AndreyGatsuk wants to merge 1 commit into
AndreyGatsuk wants to merge 1 commit into
Conversation
Decode percent sequences only for file:// inputs. Preserve native paths and icon names so literal percent sequences cannot select another file. Add one URI regression test covering normalization edge cases, decoded MPRIS artwork, notification image-path ingestion, and history persistence. Register it with Meson. Validated with just format, the debug build, all 113 tests, just lint, and clang-tidy for the expanded test. Verified notification toasts, history, image-path snapshots, and MPRIS artwork in nested Niri.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Only percent-decode
file://inputs inuri::normalizeFileUrl, preserving plain filesystem paths and icon names verbatim. Add a regression test and register it with Meson.The change applies to all four consumers of this shared helper:
image-path/image_pathhints.Motivation
Noctalia already supports absolute filesystem paths for notification icons. The existing notification test script explicitly exercises both
/usr/share/pixmaps/steam.pngandfile:///usr/share/pixmaps/steam.png.The notification service forwards icon values without URI encoding. The toast icon resolver then normalizes them and uses the resulting absolute path for filesystem access.
RFC 3986 §2.1 defines percent-encoding for URI components, and RFC 8089 §4 describes its use when representing filesystem names as file URIs. Native Linux pathnames follow the byte-based rules documented in pathname(7);
%20in a native filename is a literal sequence, not an encoded space.Previously,
/tmp/icon%20name.pngwas incorrectly converted to/tmp/icon name.png, potentially selecting a different file or failing to find the requested image. This fix preserves literal percent sequences in plain paths while retaining decoding forfile://inputs.Type of Change
Testing
The
uriregression test fails with the original URI implementation and passes with the fix. It covers:%2Fand%00, icon names, localhost file URIs, lowercase hex escapes, empty input, and HTTP(S) rejection.image-pathandimage_path, checking the captured pixels.Two distinct PNG files ensure that accidentally selecting the filename containing a space cannot pass as a successful load. Both native paths and encoded file URIs are exercised. A separate filesystem reproduction also confirmed that the original code opened the wrong file, while the fixed code opened the requested file.
Completed local CI checks:
just formatwith clang-format 22.1.8.just build: debug build passed.just test debug --print-errorlogs: all 113 tests passed, includinguri.just lint: all 572 production translation units passed.clang-tidy -p build-debug tests/uri_test.cpp --warnings-as-errors='*': passed.git diff --check: passed.All four affected consumers were also exercised with the fixed debug build on Niri 26.04 running as a nested Wayland compositor, using isolated configuration and private D-Bus sessions:
app_iconargument.image-path: PNG paths were sent in the hint with an emptyapp_icon. The original PNG files were then deleted before capturing the displayed notifications.mpris:artUrland emitted metadata changes. The artwork was checked in Noctalia's media panel.Each visual check used two distinct image files: a green check and a red cross. All three inputs produced the expected result:
%20%2520%20Manual Coverage
Screenshots / Videos
1. Notification toasts (
app_icon)2. Notification history
The same notifications after dismissing the toasts, shown newest first.
3. Notification image-path
Notifications sent with an empty
app_iconand animage-pathhint. Source PNG files were removed after notification ingestion.4. MPRIS artwork
Three cropped captures from the media panel, placed side by side in input order. The captures show sequential states of the same test player.
The red cross is the expected test image for the filename containing a space. Screenshots are crops of the actual Noctalia session.
Checklist
CONTRIBUTING.md.just formatwith clang-format v22+ installed, or this PR has no code changes.docs/user/when this PR changes documented behavior or configuration, or this PR does not require documentation changes.assets/translations/en.json, or this PR adds no new user-facing strings.