c00a4648a4
Refactor and fix `parse_prefix` on Windows This PR is an extension of #78692 as well as a general refactor of `parse_prefix`: **Fixes**: There are two errors in the current implementation of `parse_prefix`: Firstly, in the current implementation only `\` is recognized as a separator character in device namespace prefixes. This behavior is only correct for verbatim paths; `"\\.\C:/foo"` should be parsed as `"C:"` instead of `"C:/foo"`. Secondly, the current implementation only handles single separator characters. In non-verbatim paths a series of separator characters should be recognized as a single boundary, e.g. the UNC path `"\\localhost\\\\\\C$\foo"` should be parsed as `"\\localhost\\\\\\C$"` and then `UNC(server: "localhost", share: "C$")`, but currently it is not parsed at all, because it starts being parsed as `\\localhost\` and then has an invalid empty share location. Paths like `"\\.\C:/foo"` and `"\\localhost\\\\\\C$\foo"` are valid on Windows, they are equivalent to just `"C:\foo"`. **Refactoring**: All uses of `&[u8]` within `parse_prefix` are extracted to helper functions and`&OsStr` is used instead. This reduces the number of places unsafe is used: - `get_first_two_components` is adapted to the more general `parse_next_component` and used in more places - code for parsing drive prefixes is extracted to `parse_drive` |
||
---|---|---|
.. | ||
backtrace | ||
collections | ||
env | ||
error | ||
f32 | ||
f64 | ||
ffi | ||
fs | ||
io | ||
lazy | ||
memchr | ||
net | ||
num | ||
os | ||
panic | ||
path | ||
prelude | ||
process | ||
sync | ||
sys | ||
sys_common | ||
thread | ||
time | ||
alloc.rs | ||
ascii.rs | ||
backtrace.rs | ||
env.rs | ||
error.rs | ||
f32.rs | ||
f64.rs | ||
fs.rs | ||
future.rs | ||
keyword_docs.rs | ||
lazy.rs | ||
lib.rs | ||
macros.rs | ||
memchr.rs | ||
num.rs | ||
panic.rs | ||
panicking.rs | ||
path.rs | ||
primitive_docs.rs | ||
process.rs | ||
rt.rs | ||
time.rs |