[ https://issues.apache.org/jira/browse/IO-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17726474#comment-17726474 ]
Miguel Munoz edited comment on IO-552 at 5/26/23 5:47 AM: ---------------------------------------------------------- Since the tilde is a valid character in file names, it seems to me that this method, in fact this whole class, should not honor shell conventions, except for methods that explicitly say so, like the wildcard() method. The File class doesn't, and the Path class gets its file names from the File class. If the user needs to include the home directory, they can get its value by calling System.getProperty("user.home"). (It returns a string with a leading slash but no trailing slash.) However, given the current behavior, this creates a serious backwards compatibility problem. We could create a new method called concatStrict() (I'm open to suggestions here), that doesn't honor the shell convention. If we take this road, we would need to be clear in both JavaDocs about how the method handles the tilde character, and each method's JavaDocs should mention the other method. was (Author: swingguy1...@yahoo.com): Since the tilde is a valid character in file names, it seems to me that this method, in fact this whole library, should not honor shell conventions. The File class doesn't, and the Path class gets its file names from the File class. If the user needs to include the home directory, they can get its value by calling System.getProperty("user.home"). (It returns a string with a leading slash but no trailing slash.) However, given the current behavior, this creates a serious backwards compatibility problem. We could create a new method called concatStrict() (I'm open to suggestions here), that doesn't honor the shell convention. If we take this road, we would need to be clear in both JavaDocs about how the method handles the tilde character, and each method's JavaDocs should mention the other method. Before we go down this road, we should look at where else this library honors the shell convention. > FilenameUtils.concat fails if second argument (fullFilenameToAdd) starts with > '~' (tilde) > ----------------------------------------------------------------------------------------- > > Key: IO-552 > URL: https://issues.apache.org/jira/browse/IO-552 > Project: Commons IO > Issue Type: Bug > Components: Utilities > Affects Versions: 2.2, 2.5 > Environment: Windows 7 64bit, JavaVM 1.8 32bit > Reporter: Jochen Tümmers > Priority: Critical > Time Spent: 2h 40m > Remaining Estimate: 0h > > {{FilenameUtils.concat("c:/temp", "~abc.txt") returns "~abc.txt/" instead of > "c:/temp/~abc.txt".}} > As a result, the file would be created in the user's home directory instead > of c:/temp. > (Note: I Had to replace all instances of double backslashes that would > normally appear in the java code with forward slashes as the editor cannot > handle backslashes properly.) > commons io 2.2. and 2.5 behave the same. 2.3 and 2.4 not tested. -- This message was sent by Atlassian Jira (v8.20.10#820010)