* Detects unsafe absolute paths in zip entries that should be ignored. * Treats leading '/' as absolute, Windows drive roots like 'C:/' as absolute, * and common Android/Linux device roots like '/data', '/root', '/system'. * @param {string} p
(p)
| 370 | * @param {string} p |
| 371 | */ |
| 372 | function isUnsafeAbsolutePath(p) { |
| 373 | if (!p) return false; |
| 374 | const s = String(p); |
| 375 | if (/^[A-Za-z]:[\\\/]/.test(s)) return true; // Windows drive root |
| 376 | if (s.startsWith("//")) return true; // network path |
| 377 | if (s.startsWith("/")) { |
| 378 | return ( |
| 379 | s.startsWith("/data") || |
| 380 | s.startsWith("/system") || |
| 381 | s.startsWith("/vendor") || |
| 382 | s.startsWith("/storage") || |
| 383 | s.startsWith("/sdcard") || |
| 384 | s.startsWith("/root") || |
| 385 | true // any leading slash is unsafe |
| 386 | ); |
| 387 | } |
| 388 | return false; |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Resolves Dependencies Manifest with given ids. |
no test coverage detected