You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rick Latrine (Created) (JIRA)" <ji...@apache.org> on 2012/01/17 10:58:40 UTC
[jira] [Created] (IO-299) getPrefixLength returns null if filename
has leading slashes
getPrefixLength returns null if filename has leading slashes
------------------------------------------------------------
Key: IO-299
URL: https://issues.apache.org/jira/browse/IO-299
Project: Commons IO
Issue Type: Bug
Components: Utilities
Affects Versions: 2.1, 2.0.1
Reporter: Rick Latrine
Situation:
FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
FilenameUtils.normalize("////I don't want to become null!") returns null.
Problem:
Expected was: "I don't want to become null!"
The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
The root problem is found in following lines of code:
{code:title=FilenameUtils.getPrefixLength}
...
int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
return -1;
}
...
{code}
Solution:
All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:09 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
\\I don't want to become null!
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:11 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
Same with the other slash
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
\\I don't want to become null!
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:09 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\I don't want to become null!"
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:08 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\\\I don't want to become null!"
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (IO-299) getPrefixLength returns null if
filename has leading slashes
Posted by "Joerg Schaible (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206766#comment-13206766 ]
Joerg Schaible commented on IO-299:
-----------------------------------
Slashes in Unix are merged, so {noformat}ls ////////tmp{noformat} is actually {noformat}ls /tmp{noformat}
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (IO-299) getPrefixLength returns null if
filename has leading slashes
Posted by "Sebb (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206805#comment-13206805 ]
Sebb commented on IO-299:
-------------------------
The Javadoc says clearly that Unix and Windows are treated the same, also that invalid names return null.
Although double-slashes are collapsed to a single slash, this does not apply at the start of a path, because there they are used for UNC names in Windows.
As far as I can tell, the current behaviour is correct, because UNC paths must have a valid server name.
The Javadoc should probably be updated to clarify this; it would help to add some examples (and test cases if necessary).
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (IO-299) getPrefixLength returns null if
filename has leading slashes
Posted by "Thilina Dampahala (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala commented on IO-299:
--------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix: "//I don't want to become null!"
In Windows: "\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:08 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\\I don't want to become null!"
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (IO-299) getPrefixLength returns null
if filename has leading slashes
Posted by "Thilina Dampahala (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/IO-299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13206439#comment-13206439 ]
Thilina Dampahala edited comment on IO-299 at 2/12/12 4:07 PM:
---------------------------------------------------------------
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix:
"//I don't want to become null!"
In Windows:
"\\I don't want to become null!"
Any ideas on this?
was (Author: thdamp):
In this case for your input "////I don't want to become null!", I think the expected output should be
In Unix: "//I don't want to become null!"
In Windows: "\\I don't want to become null!"
Any ideas on this?
> getPrefixLength returns null if filename has leading slashes
> ------------------------------------------------------------
>
> Key: IO-299
> URL: https://issues.apache.org/jira/browse/IO-299
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.1, 2.1
> Reporter: Rick Latrine
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Situation:
> FilenameUtils.getPrefixLength is used in FilenameUtils.doNormalize.
> FilenameUtils.normalize("////I don't want to become null!") returns null.
> Problem:
> Expected was: "I don't want to become null!"
> The method FilenameUtils.getPrefixLength returns -1 for the mentioned string.
> The root problem is found in following lines of code:
> {code:title=FilenameUtils.getPrefixLength}
> ...
> int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
> int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
> if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) {
> return -1;
> }
> ...
> {code}
> Solution:
> All leading slashes should be ignored at all, but considering the rest of the string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira