From 783e35cf73f7763f490b1e8a95804007f14fb67a Mon Sep 17 00:00:00 2001 From: comp500 Date: Sun, 17 Jul 2022 01:07:48 +0100 Subject: [PATCH] Fix OutOfBoundsException when parsing a single letter path component --- .../infra/packwiz/installer/target/path/PackwizPath.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/link/infra/packwiz/installer/target/path/PackwizPath.kt b/src/main/kotlin/link/infra/packwiz/installer/target/path/PackwizPath.kt index f9e7bef..13efb98 100644 --- a/src/main/kotlin/link/infra/packwiz/installer/target/path/PackwizPath.kt +++ b/src/main/kotlin/link/infra/packwiz/installer/target/path/PackwizPath.kt @@ -43,9 +43,11 @@ abstract class PackwizPath>(path: String? = null) { } else { canonicalised += componentNorm // Don't allow volume letters (allows traversal to the root on Windows) - if (componentNorm[0] in 'a'..'z' || componentNorm[0] in 'A'..'Z') { - if (componentNorm[1] == ':') { - throw RequestException.Validation.PathContainsVolumeLetter(path) + if (componentNorm.length == 2) { + if (componentNorm[0] in 'a'..'z' || componentNorm[0] in 'A'..'Z') { + if (componentNorm[1] == ':') { + throw RequestException.Validation.PathContainsVolumeLetter(path) + } } } }