commons-vfs
commons-vfs copied to clipboard
Fix for incorrect detection of %2f as separator at a few places in UriParser
The detection of %2f in UriParser.readNonSeparator()
is incorrect as it always compare a String of length 2 with a String of length 3.
After the fix, a unit test failed:
NamingTests
-> assertSameName(path, name, "foo%2f..%2fa", scope);
The reason was before the fix the resolved path was '/Java/libraries/commons-vfs/commons-vfs2/target/test-classes/test-data/read-tests/foo%2f..%2fa'
After the fix the resolved path is '/Java/libraries/commons-vfs/commons-vfs2/target/test-classes/test-data/read-tests%2fa'
AbstractFileName.checkName
(with scope child) wasn't failing first as path.charAt(baseLen)
was '/' (the '/' before foo)
then it was failing as the separator at baseLen was %2f and not '/'.
So I've changed the UriParser.PathNormalizer.readSeparator()
to also normalize the '%2f' to '/'. This fixes the unit tests.
While adding more unit tests, I also noticed the different handling of '/' and %2f in UriParser.normalisePath()
and fixed it.