Skip to content

Commit b1ce924

Browse files
committed
fix: only treat known system 8.3 aliases as abnormal paths
1 parent fc01fa4 commit b1ce924

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

‎src-tauri/src/safety.rs‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,27 +355,21 @@ pub fn protected_fs_prefixes() -> Vec<String> {
355355
}
356356

357357
/// True when the path uses an abnormal Windows shape that can bypass prefix/segment matching:
358-
/// extended-length / device prefixes (`\\?\`, `\\.\`) or 8.3 short-name segments (`NAME~1`).
359-
/// S-R6-05: these must never be treated as ordinary safe paths or non-library paths.
358+
/// extended-length / device prefixes (`\\?\`, `\\.\`) or **known protected** 8.3 short names
359+
/// (`PROGRA~1`, `DOCUME~1`, …). Generic profile short names (`Users\RUNNER~1\…`) stay legal.
360360
pub fn is_abnormal_path_shape(p: &str) -> bool {
361361
let s = p.replace('/', "\\");
362-
// Extended-length / device / UNC-device prefixes anywhere in the path.
363362
if s.contains("\\\\?\\") || s.contains("\\\\.\\") {
364363
return true;
365364
}
366-
// 8.3 short-name segment shape: `NAME~DIGITS` optionally followed by an extension.
365+
const SHORTS: &[&str] = &[
366+
"progra~1", "progra~2", "docume~1", "mydocu~1", "downlo~1", "applic~1", "locals~1",
367+
"shared~1", "public~1",
368+
];
367369
for seg in s.split('\\') {
368370
let low = seg.to_ascii_lowercase();
369-
let Some(tilde) = low.find('~') else {
370-
continue;
371-
};
372-
let rest = &low[tilde + 1..];
373-
let digits = rest.chars().take_while(|c| c.is_ascii_digit()).count();
374-
if digits == 0 {
375-
continue;
376-
}
377-
let after = &rest[digits..];
378-
if after.is_empty() || after.starts_with('.') {
371+
let base = low.split('.').next().unwrap_or(&low);
372+
if SHORTS.contains(&base) {
379373
return true;
380374
}
381375
}

0 commit comments

Comments
 (0)