Expand description
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:evilform, because on WindowsC:evilstill escapes the intended extraction root; and - the SARIF URI formatter wanted the STRICT sense: only a fully-qualified
absolute path
C:\dir/C:/diris “absolute”; the drive-relativeC:relresolves 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/).
Functions§
- has_
windows_ drive_ prefix - True iff
sbegins 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-qualifiedC:\eviland the drive-relativeC:evil, both of which can escape an intended extraction root on Windows. - is_
windows_ absolute - True iff
sis a fully-qualified Windows absolute path: a drive letter, a colon, and a path separator (C:\dirorC:/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-relativeC:relis NOT absolute and returnsfalse.