@@ -195,7 +195,7 @@ public class FilenameUtils {
195195 * @param basePath the base path to attach to, always treated as a path
196196 * @param fullFileNameToAdd the fileName (or path) to attach to the base
197197 * @return the concatenated path, or null if invalid
198- * @throws IllegalArgumentException if the result path contains null bytes
198+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
199199 */
200200 public static String concat (final String basePath , final String fullFileNameToAdd ) {
201201 final int prefix = getPrefixLength (fullFileNameToAdd );
@@ -261,7 +261,7 @@ public static boolean directoryContains(final String canonicalParent, final Stri
261261 * @param fileName the fileName
262262 * @param includeSeparator true to include the end separator
263263 * @return the path
264- * @throws IllegalArgumentException if the result path contains null bytes
264+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
265265 */
266266 private static String doGetFullPath (final String fileName , final boolean includeSeparator ) {
267267 // TODO: Does not (indirectly) call requireNonNullChars in all cases for result
@@ -295,7 +295,7 @@ private static String doGetFullPath(final String fileName, final boolean include
295295 * @param fileName the fileName
296296 * @param separatorAdd 0 to omit the end separator, 1 to return it
297297 * @return the path
298- * @throws IllegalArgumentException if the result path contains null bytes
298+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
299299 */
300300 private static String doGetPath (final String fileName , final int separatorAdd ) {
301301 if (fileName == null ) {
@@ -320,7 +320,7 @@ private static String doGetPath(final String fileName, final int separatorAdd) {
320320 * @param separator The separator character to use
321321 * @param keepSeparator true to keep the final separator
322322 * @return the normalized fileName
323- * @throws IllegalArgumentException if the fileName contains null bytes
323+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
324324 */
325325 private static String doNormalize (final String fileName , final char separator , final boolean keepSeparator ) {
326326 if (fileName == null ) {
@@ -452,7 +452,7 @@ public static boolean equals(String fileName1, String fileName2, final boolean n
452452 if (fileName1 == null || fileName2 == null ) {
453453 return fileName1 == null && fileName2 == null ;
454454 }
455- // TODO: Should IllegalArgumentException thrown by `normalize` for null bytes be
455+ // TODO: Should IllegalArgumentException thrown by `normalize` for null characters be
456456 // handled? (and for example `false` be returned instead); If not, have to mention it
457457 // in javadoc of this method and callers
458458 if (normalized ) {
@@ -574,7 +574,7 @@ private static int getAdsCriticalOffset(final String fileName) {
574574 *
575575 * @param fileName the fileName to query, null returns null
576576 * @return the name of the file without the path, or an empty string if none exists
577- * @throws IllegalArgumentException if the fileName contains null bytes
577+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
578578 */
579579 public static String getBaseName (final String fileName ) {
580580 return removeExtension (getName (fileName ));
@@ -618,7 +618,7 @@ public static String getExtension(final String fileName) throws IllegalArgumentE
618618 if (index == NOT_FOUND ) {
619619 return EMPTY_STRING ;
620620 }
621- // TODO: Should check for null bytes ?
621+ // TODO: Should check for null characters ?
622622 return fileName .substring (index + 1 );
623623 }
624624
@@ -648,7 +648,7 @@ public static String getExtension(final String fileName) throws IllegalArgumentE
648648 *
649649 * @param fileName the fileName to query, null returns null
650650 * @return the path of the file, an empty string if none exists, null if invalid
651- * @throws IllegalArgumentException if the result path contains null bytes
651+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
652652 */
653653 public static String getFullPath (final String fileName ) {
654654 return doGetFullPath (fileName , true );
@@ -681,7 +681,7 @@ public static String getFullPath(final String fileName) {
681681 *
682682 * @param fileName the fileName to query, null returns null
683683 * @return the path of the file, an empty string if none exists, null if invalid
684- * @throws IllegalArgumentException if the result path contains null bytes
684+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
685685 */
686686 public static String getFullPathNoEndSeparator (final String fileName ) {
687687 return doGetFullPath (fileName , false );
@@ -705,7 +705,7 @@ public static String getFullPathNoEndSeparator(final String fileName) {
705705 *
706706 * @param fileName the fileName to query, null returns null
707707 * @return the name of the file without the path, or an empty string if none exists
708- * @throws IllegalArgumentException if the fileName contains null bytes
708+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
709709 */
710710 public static String getName (final String fileName ) {
711711 if (fileName == null ) {
@@ -738,7 +738,7 @@ public static String getName(final String fileName) {
738738 *
739739 * @param fileName the fileName to query, null returns null
740740 * @return the path of the file, an empty string if none exists, null if invalid
741- * @throws IllegalArgumentException if the result path contains null bytes
741+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
742742 */
743743 public static String getPath (final String fileName ) {
744744 return doGetPath (fileName , 1 );
@@ -769,7 +769,7 @@ public static String getPath(final String fileName) {
769769 *
770770 * @param fileName the fileName to query, null returns null
771771 * @return the path of the file, an empty string if none exists, null if invalid
772- * @throws IllegalArgumentException if the result path contains null bytes
772+ * @throws IllegalArgumentException if the result path contains the null character ({@code U+0000})
773773 */
774774 public static String getPathNoEndSeparator (final String fileName ) {
775775 return doGetPath (fileName , 0 );
@@ -805,7 +805,7 @@ public static String getPathNoEndSeparator(final String fileName) {
805805 *
806806 * @param fileName the fileName to query, null returns null
807807 * @return the prefix of the file, null if invalid
808- * @throws IllegalArgumentException if the result contains null bytes
808+ * @throws IllegalArgumentException if the result contains the null character ({@code U+0000})
809809 */
810810 public static String getPrefix (final String fileName ) {
811811 if (fileName == null ) {
@@ -850,7 +850,7 @@ public static String getPrefix(final String fileName) {
850850 * ~user --> 6 --> named user (slash added)
851851 * //server/a/b/c.txt --> 9
852852 * ///a/b/c.txt --> -1 --> error
853- * C: --> 0 --> valid filename as only null byte and / are reserved characters
853+ * C: --> 0 --> valid filename as only null character and / are reserved characters
854854 * </pre>
855855 * <p>
856856 * The output will be the same irrespective of the machine that the code is running on.
@@ -999,7 +999,7 @@ private static boolean isEmpty(final String string) {
999999 * @param fileName the fileName to query, null returns false
10001000 * @param extensions the extensions to check for, null checks for no extension
10011001 * @return true if the fileName is one of the extensions
1002- * @throws IllegalArgumentException if the fileName contains null bytes
1002+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
10031003 */
10041004 public static boolean isExtension (final String fileName , final Collection <String > extensions ) {
10051005 if (fileName == null ) {
@@ -1029,7 +1029,7 @@ public static boolean isExtension(final String fileName, final Collection<String
10291029 * @param fileName the fileName to query, null returns false
10301030 * @param extension the extension to check for, null or empty checks for no extension
10311031 * @return true if the fileName has the specified extension
1032- * @throws IllegalArgumentException if the fileName contains null bytes
1032+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
10331033 */
10341034 public static boolean isExtension (final String fileName , final String extension ) {
10351035 if (fileName == null ) {
@@ -1053,7 +1053,7 @@ public static boolean isExtension(final String fileName, final String extension)
10531053 * @param fileName the fileName to query, null returns false
10541054 * @param extensions the extensions to check for, null checks for no extension
10551055 * @return true if the fileName is one of the extensions
1056- * @throws IllegalArgumentException if the fileName contains null bytes
1056+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
10571057 */
10581058 public static boolean isExtension (final String fileName , final String ... extensions ) {
10591059 if (fileName == null ) {
@@ -1266,7 +1266,7 @@ private static boolean isValidHostName(final String name) {
12661266 *
12671267 * @param fileName the fileName to normalize, null returns null
12681268 * @return the normalized fileName, or null if invalid
1269- * @throws IllegalArgumentException if the fileName contains null bytes
1269+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
12701270 */
12711271 public static String normalize (final String fileName ) {
12721272 return doNormalize (fileName , SYSTEM_NAME_SEPARATOR , true );
@@ -1314,7 +1314,7 @@ public static String normalize(final String fileName) {
13141314 * @param unixSeparator {@code true} if a unix separator should
13151315 * be used or {@code false} if a windows separator should be used.
13161316 * @return the normalized fileName, or null if invalid
1317- * @throws IllegalArgumentException if the fileName contains null bytes
1317+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
13181318 * @since 2.0
13191319 */
13201320 public static String normalize (final String fileName , final boolean unixSeparator ) {
@@ -1361,7 +1361,7 @@ public static String normalize(final String fileName, final boolean unixSeparato
13611361 *
13621362 * @param fileName the fileName to normalize, null returns null
13631363 * @return the normalized fileName, or null if invalid
1364- * @throws IllegalArgumentException if the fileName contains null bytes
1364+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
13651365 */
13661366 public static String normalizeNoEndSeparator (final String fileName ) {
13671367 return doNormalize (fileName , SYSTEM_NAME_SEPARATOR , false );
@@ -1408,7 +1408,7 @@ public static String normalizeNoEndSeparator(final String fileName) {
14081408 * @param unixSeparator {@code true} if a unix separator should
14091409 * be used or {@code false} if a windows separator should be used.
14101410 * @return the normalized fileName, or null if invalid
1411- * @throws IllegalArgumentException if the fileName contains null bytes
1411+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
14121412 * @since 2.0
14131413 */
14141414 public static String normalizeNoEndSeparator (final String fileName , final boolean unixSeparator ) {
@@ -1431,7 +1431,7 @@ public static String normalizeNoEndSeparator(final String fileName, final boolea
14311431 *
14321432 * @param fileName the fileName to query, null returns null
14331433 * @return the fileName minus the extension
1434- * @throws IllegalArgumentException if the fileName contains null bytes
1434+ * @throws IllegalArgumentException if the fileName contains the null character ({@code U+0000})
14351435 */
14361436 public static String removeExtension (final String fileName ) {
14371437 if (fileName == null ) {
@@ -1447,18 +1447,18 @@ public static String removeExtension(final String fileName) {
14471447 }
14481448
14491449 /**
1450- * Checks the input for null bytes , a sign of unsanitized data being passed to to file level functions.
1450+ * Checks the input for null characters ({@code U+0000}) , a sign of unsanitized data being passed to to file level functions.
14511451 *
14521452 * This may be used for poison byte attacks.
14531453 *
14541454 * @param path the path to check
14551455 * @return The input
1456- * @throws IllegalArgumentException if path contains null bytes
1456+ * @throws IllegalArgumentException if path contains the null character ({@code U+0000})
14571457 */
14581458 private static String requireNonNullChars (final String path ) {
14591459 if (path .indexOf (0 ) >= 0 ) {
14601460 throw new IllegalArgumentException (
1461- "Null byte present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it" );
1461+ "Null character present in file/path name. There are no known legitimate use cases for such data, but several injection attacks may use it" );
14621462 }
14631463 return path ;
14641464 }
0 commit comments