You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sita Geßner (Jira)" <ji...@apache.org> on 2022/05/17 12:07:00 UTC
[jira] [Created] (IO-770) FilenameUtils#getFullPathNoEndSeparator has issues with windows and underscore in hostname
Sita Geßner created IO-770:
------------------------------
Summary: FilenameUtils#getFullPathNoEndSeparator has issues with windows and underscore in hostname
Key: IO-770
URL: https://issues.apache.org/jira/browse/IO-770
Project: Commons IO
Issue Type: Bug
Components: Utilities
Affects Versions: 2.11.0, 2.10.0, 2.9.0, 2.8.0, 2.7
Reporter: Sita Geßner
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
{code:java}
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()));
}
{code}
We know hostnames are not supposed to have underscores, but windows allows it and unfortunatly we have to deal with this.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)