Skip to content

Commit 27fb104

Browse files
IO-567: Implement special case handling for NTFS ADS names
fix checkstyle violation by replacing tabs with spaces
1 parent cfb682e commit 27fb104

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

src/main/java/org/apache/commons/io/FilenameUtils.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,11 @@ public static int indexOfExtension(final String filename) throws IllegalArgument
734734
return NOT_FOUND;
735735
}
736736
if (isSystemWindows()) {
737-
// Special handling for NTFS ADS: Don't accept colon in the filename.
738-
final int offset = filename.indexOf(':', getAdsCriticalOffset(filename));
739-
if (offset != -1) {
740-
throw new IllegalArgumentException("NTFS ADS separator (':') in filename is forbidden.");
741-
}
737+
// Special handling for NTFS ADS: Don't accept colon in the filename.
738+
final int offset = filename.indexOf(':', getAdsCriticalOffset(filename));
739+
if (offset != -1) {
740+
throw new IllegalArgumentException("NTFS ADS separator (':') in filename is forbidden.");
741+
}
742742
}
743743
final int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR);
744744
final int lastSeparator = indexOfLastSeparator(filename);
@@ -1070,24 +1070,24 @@ public static String getExtension(final String filename) throws IllegalArgumentE
10701070
}
10711071

10721072
private static int getAdsCriticalOffset(String filename) {
1073-
// Step 1: Remove leading path segments.
1074-
int offset1 = filename.lastIndexOf(SYSTEM_SEPARATOR);
1075-
int offset2 = filename.lastIndexOf(OTHER_SEPARATOR);
1076-
if (offset1 == -1) {
1077-
if (offset2 == -1) {
1078-
return 0;
1079-
} else {
1080-
return offset2 + 1;
1081-
}
1082-
} else {
1083-
if (offset2 == -1) {
1084-
return offset1+1;
1085-
} else {
1086-
return Math.max(offset1, offset2)+1;
1087-
}
1088-
}
1073+
// Step 1: Remove leading path segments.
1074+
int offset1 = filename.lastIndexOf(SYSTEM_SEPARATOR);
1075+
int offset2 = filename.lastIndexOf(OTHER_SEPARATOR);
1076+
if (offset1 == -1) {
1077+
if (offset2 == -1) {
1078+
return 0;
1079+
} else {
1080+
return offset2 + 1;
1081+
}
1082+
} else {
1083+
if (offset2 == -1) {
1084+
return offset1 + 1;
1085+
} else {
1086+
return Math.max(offset1, offset2) + 1;
1087+
}
1088+
}
10891089
}
1090-
1090+
10911091
//-----------------------------------------------------------------------
10921092
/**
10931093
* Removes the extension from a filename.

0 commit comments

Comments
 (0)