Removed encoding of request to retrieve files and folders by path, to avoid double encoding via the typed client#19457
Conversation
… avoid double encoding via the typed client.
There was a problem hiding this comment.
Pull Request Overview
This PR removes manual encodeURIComponent calls on path parameters to prevent double encoding when using the typed HTTP client. It ensures that script, stylesheet, and partial-view paths are passed raw and rely on the client’s automatic encoding.
- Removed
encodeURIComponent(path)wrappers from allgetByPath,putByPath,deleteByPath, and rename service calls. - Confirmed behavior works under IIS without path errors.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| stylesheet-folder.server.data-source.ts | Removed manual encoding for folder retrieval/deletion paths |
| stylesheet-detail.server.data-source.ts | Removed manual encoding for stylesheet CRUD paths |
| rename-stylesheet.server.data-source.ts | Removed manual encoding for rename action |
| script-folder.server.data-source.ts | Removed manual encoding for folder retrieval/deletion paths |
| script-detail.server.data-source.ts | Removed manual encoding for script CRUD paths |
| rename-script.server.data-source.ts | Removed manual encoding for rename action |
| partial-view-folder.server.data-source.ts | Removed manual encoding for folder retrieval/deletion paths |
| partial-view-detail.server.data-source.ts | Removed manual encoding for partial-view CRUD paths |
| rename-partial-view.server.data-source.ts | Removed manual encoding for rename action |
Comments suppressed due to low confidence (2)
src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/repository/stylesheet-folder.server.data-source.ts:55
- Add unit or integration tests covering paths with special characters (spaces, symbols) to verify that removing manual encoding still yields correct HTTP requests.
path: { path },
src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/tree/folder/repository/stylesheet-folder.server.data-source.ts:55
- [nitpick] The same change is repeated across many data sources; consider abstracting path parameter handling into a shared helper or base class to reduce duplication.
path: { path },
...ckages/templating/stylesheets/tree/folder/repository/stylesheet-folder.server.data-source.ts
Show resolved
Hide resolved
iOvergaard
left a comment
There was a problem hiding this comment.
This works great, but I see we have other such cases in the code base. I will spend a bit of time testing those out and applying the same fix if necessary.
iOvergaard
left a comment
There was a problem hiding this comment.
Found a single thing in the log viewer, but was not directly related to the http client. I removed the extra encodeUriComponent. LGTM.
Prerequisites
Fixes: #19446
Description
In testing we found that when running under IIS errors were thrown when requesting script, stylesheet and partial view files. Using Kestrel didn't show these issues. The requested path string was being double encoded - once in our own code and once automatically via the typed HTTP client. Seemingly the latter web server could handle this, but not the former.
Removing the double encoding by removing our initial encoding before the request is passed to the typed API client looks to resolve the issue.
Testing
Verify script, stylesheet and partial view files and folders can be created, retrieved, updated and deleted (I've done this on Windows, using both IISExpress and Kestrel).