Skip to content

Remove unsafe code from Uri path dot & slash unescaping - #121680

Merged
MihaZupan merged 1 commit into
dotnet:mainfrom
MihaZupan:uri-unsafe-unescapeonly
Nov 18, 2025
Merged

MihaZupan merged 1 commit into
dotnet:mainfrom
MihaZupan:uri-unsafe-unescapeonly

Conversation

@MihaZupan

Copy link
Copy Markdown
Member

Together with all the other recent PRs, this removes the only remaining use of unsafe from Uri 🎉.

This helper is only used for file Uris where the path wasn't already in a canonical form. Perf is about the same.

@MihaZupan MihaZupan added this to the 11.0.0 milestone Nov 16, 2025
@MihaZupan
MihaZupan requested a review from a team November 16, 2025 05:46
@MihaZupan MihaZupan self-assigned this Nov 16, 2025
@MihaZupan
MihaZupan marked this pull request as ready for review November 16, 2025 05:46
Copilot AI review requested due to automatic review settings November 16, 2025 05:46
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR successfully removes unsafe code from URI path dot and slash unescaping, eliminating the last remaining use of unsafe from the Uri class. The refactoring replaces a pointer-based implementation with a safe, span-based approach while maintaining equivalent functionality.

Key Changes:

  • Replaced the unsafe method UnescapeOnly with a safe method UnescapePathSlashesAndDots
  • Removed unsafe modifier from GetCanonicalPath method
  • Refactored from pointer arithmetic with goto-based control flow to a cleaner loop-based implementation using Span

@MihaZupan
MihaZupan merged commit 404a358 into dotnet:main Nov 18, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants