You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stefan Bodewig <bo...@apache.org> on 2004/11/26 08:56:40 UTC
[IO] FilenameUtils#getPrefixLength is broken on Unix
Hi,
this is the manual version of what Gump is trying to tell you 8-)
FilenameUtils.getPrefixLength fails on Unix if you pass a string of
length one as argument since it unconditionally tries to access the
second character (just to never use it). Therefore the test case
fails since it tests "/".
The trivial patch appended fixes this problem
It will not fix the build since the tests still fails, but I'm not
sure whether the code ot the test is wrong. The test failure
remaining is
[junit] Testcase: testNormalize took 0,02 sec
[junit] FAILED
[junit] Check if '/../' normalized to 'null', was '' expected:<null> but was:<>
[junit] junit.framework.ComparisonFailure: Check if '/../' normalized to 'null', was '' expected:<null> but was:<>
Cheers
Stefan
Index: io/src/java/org/apache/commons/io/FilenameUtils.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/io/src/java/org/apache/commons/io/FilenameUtils.java,v
retrieving revision 1.27
diff -u -r1.27 FilenameUtils.java
--- io/src/java/org/apache/commons/io/FilenameUtils.java 23 Nov 2004 00:04:29 -0000 1.27
+++ io/src/java/org/apache/commons/io/FilenameUtils.java 26 Nov 2004 07:51:24 -0000
@@ -416,7 +416,6 @@
}
} else {
char ch0 = filename.charAt(0);
- char ch1 = filename.charAt(1);
if (ch0 == '~') {
if (len == 1) {
return -1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [IO] FilenameUtils#getPrefixLength is broken on Unix
Posted by Martin Cooper <mf...@gmail.com>.
I've removed the offending line, as suggested. I have not fixed the
test problems, though. I'll leave that for Stephen. ;-)
FYI, the tests also fail on Windows, but the failure I see is:
[junit] Testcase: testNormalize took 0.02 sec
[junit] FAILED
[junit] Check if '///' normalized to '\', was 'null' expected:<\>
but was:<null>
[junit] junit.framework.ComparisonFailure: Check if '///'
normalized to '\', was 'null' expected:<\> but was:<null>
--
Martin Cooper
On Fri, 26 Nov 2004 08:56:40 +0100, Stefan Bodewig <bo...@apache.org> wrote:
> Hi,
>
> this is the manual version of what Gump is trying to tell you 8-)
>
> FilenameUtils.getPrefixLength fails on Unix if you pass a string of
> length one as argument since it unconditionally tries to access the
> second character (just to never use it). Therefore the test case
> fails since it tests "/".
>
> The trivial patch appended fixes this problem
>
> It will not fix the build since the tests still fails, but I'm not
> sure whether the code ot the test is wrong. The test failure
> remaining is
>
> [junit] Testcase: testNormalize took 0,02 sec
> [junit] FAILED
> [junit] Check if '/../' normalized to 'null', was '' expected:<null> but was:<>
> [junit] junit.framework.ComparisonFailure: Check if '/../' normalized to 'null', was '' expected:<null> but was:<>
>
> Cheers
>
> Stefan
>
> Index: io/src/java/org/apache/commons/io/FilenameUtils.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-commons/io/src/java/org/apache/commons/io/FilenameUtils.java,v
> retrieving revision 1.27
> diff -u -r1.27 FilenameUtils.java
> --- io/src/java/org/apache/commons/io/FilenameUtils.java 23 Nov 2004 00:04:29 -0000 1.27
> +++ io/src/java/org/apache/commons/io/FilenameUtils.java 26 Nov 2004 07:51:24 -0000
> @@ -416,7 +416,6 @@
> }
> } else {
> char ch0 = filename.charAt(0);
> - char ch1 = filename.charAt(1);
> if (ch0 == '~') {
> if (len == 1) {
> return -1;
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [IO] FilenameUtils#getPrefixLength is broken on Unix
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Thanks, I was aware that I'd checked in bad code, but
hadn't been able to access a system since to be able
to fix it. I might get to it tonight if someone
doesn't beat me to it.
Stephen
--- Stefan Bodewig <bo...@apache.org> wrote:
> Hi,
>
> this is the manual version of what Gump is trying to
> tell you 8-)
>
> FilenameUtils.getPrefixLength fails on Unix if you
> pass a string of
> length one as argument since it unconditionally
> tries to access the
> second character (just to never use it). Therefore
> the test case
> fails since it tests "/".
>
> The trivial patch appended fixes this problem
>
> It will not fix the build since the tests still
> fails, but I'm not
> sure whether the code ot the test is wrong. The
> test failure
> remaining is
>
> [junit] Testcase: testNormalize took 0,02 sec
> [junit] FAILED
> [junit] Check if '/../' normalized to 'null',
> was '' expected:<null> but was:<>
> [junit] junit.framework.ComparisonFailure: Check
> if '/../' normalized to 'null', was ''
> expected:<null> but was:<>
>
> Cheers
>
> Stefan
>
> Index:
> io/src/java/org/apache/commons/io/FilenameUtils.java
>
===================================================================
> RCS file:
>
/home/cvspublic/jakarta-commons/io/src/java/org/apache/commons/io/FilenameUtils.java,v
> retrieving revision 1.27
> diff -u -r1.27 FilenameUtils.java
> ---
> io/src/java/org/apache/commons/io/FilenameUtils.java
> 23 Nov 2004 00:04:29 -0000 1.27
> +++
> io/src/java/org/apache/commons/io/FilenameUtils.java
> 26 Nov 2004 07:51:24 -0000
> @@ -416,7 +416,6 @@
> }
> } else {
> char ch0 = filename.charAt(0);
> - char ch1 = filename.charAt(1);
> if (ch0 == '~') {
> if (len == 1) {
> return -1;
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org