1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Canonical Windows-path classification predicates.
//!
//! ONE PLACE for "does this string carry a Windows drive letter". Two callers
//! previously hand-rolled a private `is_windows_absolute` with *different*
//! semantics under the *same* name, a same-name-divergence trap:
//!
//! * the archive entry-name sanitizer (a security reject) wanted the BROAD
//! sense: reject anything drive-letter-prefixed, including the drive-RELATIVE
//! `C:evil` form, because on Windows `C:evil` still escapes the intended
//! extraction root; and
//! * the SARIF URI formatter wanted the STRICT sense: only a fully-qualified
//! absolute path `C:\dir` / `C:/dir` is "absolute"; the drive-relative
//! `C:rel` resolves against the drive's current directory and is NOT absolute.
//!
//! Both are correct for their caller, so they are two DISTINCT predicates with
//! DISTINCT names, defined once here and imported where needed. No reader has to
//! guess which `is_windows_absolute` a call meant.
//!
//! Tests live in `tests/unit/winpath.rs` (KH-GAP-004: no inline test modules
//! in `src/`).
/// True iff `s` begins with a Windows drive-letter prefix (`X:`), regardless of
/// whether a path separator follows. This is the BROAD, security-oriented sense
/// used to reject untrusted archive entry names: it catches the fully-qualified
/// `C:\evil` *and* the drive-relative `C:evil`, both of which can escape an
/// intended extraction root on Windows.
/// True iff `s` is a fully-qualified Windows absolute path: a drive letter, a
/// colon, and a path separator (`C:\dir` or `C:/dir`). This is the STRICT sense
/// used when "absolute" must mean root-anchored, e.g. deciding whether a path
/// is already absolute for URI formatting. The drive-relative `C:rel` is NOT
/// absolute and returns `false`.