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

StringIndexOutOfBounds exception on FilenameUtils.getPathNoEndSeparator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.2, 1.4
    • Fix Version/s: 2.0
    • Component/s: Utilities
    • Labels:
      None
    • Environment:

      Javadoc says that method is text based. In any case, the problem has been reproduced in Windows and Linux.

      Description

      public void testFilenameUtils()

      { String path = "/foo.xml"; org.apache.commons.io.FilenameUtils.getPathNoEndSeparator(path); }

      Leads to:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1768)
      at org.apache.commons.io.FilenameUtils.doGetPath(FilenameUtils.java:705)
      at org.apache.commons.io.FilenameUtils.getPathNoEndSeparator(FilenameUtils.java:683)

        Attachments

        1. IO-179.patch
          2 kB
          Gwenaël Le Roux

          Activity

            People

            • Assignee:
              niallp Niall Pemberton
              Reporter:
              francisco Francisco Borges
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: