Skip to content

Commit

Permalink
Merge pull request #4176 from pratikmhatre/issue_4146
Browse files Browse the repository at this point in the history
Files with ambiguous names crash on extraction : Fixed
  • Loading branch information
VishalNehra authored Jul 8, 2024
2 parents 6984fc7 + 299e2fb commit 978fa99
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,23 @@ public static boolean isFileExtractable(String path) {
*/
public static String getFileName(String compressedName) {
compressedName = compressedName.toLowerCase();
if (isZip(compressedName)
|| isTar(compressedName)
|| isRar(compressedName)
|| is7zip(compressedName)
|| isXz(compressedName)
|| isLzma(compressedName)
|| isGzip(compressedName)
|| compressedName.endsWith(fileExtensionGzipTarShort)
|| compressedName.endsWith(fileExtensionBzip2TarShort)
|| isGzip(compressedName)
|| isBzip2(compressedName)
|| isLzma(compressedName)
|| isXz(compressedName)) {
boolean hasFileName = compressedName.contains(".");
if (hasFileName
&& (isZip(compressedName)
|| isTar(compressedName)
|| isRar(compressedName)
|| is7zip(compressedName)
|| isXz(compressedName)
|| isLzma(compressedName)
|| isGzip(compressedName)
|| compressedName.endsWith(fileExtensionGzipTarShort)
|| compressedName.endsWith(fileExtensionBzip2TarShort)
|| isGzip(compressedName)
|| isBzip2(compressedName)
|| isLzma(compressedName)
|| isXz(compressedName))) {
return compressedName.substring(0, compressedName.lastIndexOf("."));
} else if (isGzippedTar(compressedName)
} else if (hasFileName && isGzippedTar(compressedName)
|| isXzippedTar(compressedName)
|| isLzippedTar(compressedName)
|| isBzippedTar(compressedName)) {
Expand Down

0 comments on commit 978fa99

Please sign in to comment.