Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-770

FilenameUtils#getFullPathNoEndSeparator has issues with windows and underscore in hostname

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7, 2.8.0, 2.9.0, 2.10.0, 2.11.0
    • None
    • Utilities
    • None

    Description

      After updating commons-io to version 2.11.0 there is an issue with FilenameUtils#getFullPathNoEndSeparator only when using Windows.

      When using Linux there are no problems.

      getFullPathNoEndSeparator returns null if the hostname of the path contains an underscore. This issue occured since version 2.7

          private static void commonsIo() {
              final String result = getSubFolderFromFile(new File("\\\\sub_1.example.com\\path\\subfolder\\test.pdf"));
              // Fails in common-io:2.11.0 b/c result is null.
              System.out.println("result should be \"subfolder\", but it is: " + result);
          }
      
          private static String getSubFolderFromFile(final File file) {
              return FilenameUtils.getBaseName(FilenameUtils.getFullPathNoEndSeparator(file.getAbsolutePath()));
          }
      

      We know hostnames are not supposed to have underscores, but windows allows it and unfortunatly we have to deal with this.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sgessner Sita Geßner
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: