Normalize Windows namespace paths in path URIs (#35851)

## What changed

- Convert Windows device-namespace drive paths such as `\\?\D:\reports` and
  `\\.\D:\reports` to canonical drive-based `file:` URIs.
- Convert device-namespace UNC paths to canonical hosted `file:` URIs.
- Preserve unsupported or ambiguous namespace paths as opaque path URIs instead
  of interpreting them as filesystem paths.

## Testing

Add coverage for namespace path conversion and joining, including malformed UNC
paths, reserved device names, and volume identifiers.

GitOrigin-RevId: 234f69bc2787e5d318bc0320b94e7392abfb5602
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-07-29 00:13:06 +00:00
1 parent 101d6b8cb2
commit 8707a35113
3 files changed
+88 -1

No files matched your search

+2 -1
View File
@@ -150,7 +150,8 @@ fn normalize_path_for_platform(path: &Path) -> Cow<'_, Path> {
Cow::Borrowed(path)
}
fn normalize_windows_device_path(path: &str) -> Option<String> {
/// Normalizes Windows drive and UNC namespace aliases on any host.
pub fn normalize_windows_device_path(path: &str) -> Option<String> {
if let Some(unc) = path.strip_prefix(r"\\?\UNC\") {
return Some(format!(r"\\{unc}"));
}