[jcifs] Fix for handing file names that start with .# and ..#

Michael B Allen ioplex at gmail.com
Thu Sep 2 00:41:33 MDT 2010


Hi Jim,

I have added this to the TODO list for further investigation at a later time.

Thanks,
Mike

On Wed, Sep 1, 2010 at 3:34 PM, Jim Hurne <hurne at vivisimo.com> wrote:
> Hello Mike,
>
> We found a bug in JCIF that breaks support for file names that start with
> ".#" and "..#", and we developed a patch (see attached).
>
> The bug is a direct result of the differences between how java.net.URL and
> java.net.URLStreamHandler parse URLs (or put another way, a direct result of
> the differences between smb URLs and http URLs).  Everything works fine if
> the URL is constructed without a context (parent). However, when construcing
> a URL with a parent, the "." and ".." (of .# and ..#) are treated as
> relative path specifiers.  This is becuase everything after the hash is
> treated as a ref (anchor), and when the ref is removed, all that is left is
> the "." and "..".
>
> Examples:
>
> jcifs.Config.registerSmbURLHandler();
>
> // Works fine
> URL url = new URL("smb://some-share/dir/..#twodots");
> // prints out "url: smb://some-share/dir/..#twodots"
> System.out.println("url: " + url.toString());
>
> // Does NOT work
> URL parent = new URL("smb://some-share/dir/");
> url = new URL(parent, "..#twodots");
>
> // prints out "url: smb://some-share/#twodots"  <-- WRONG, notice that
> "/dir" is missing from the path, and how the ".." is missing
> System.out.println("url: " + url.toString());
>
> The problem affects not just URLs, but also SmbFile instances (since all of
> the constructors ultimately create a URL). The patch adds some handing for
> these special casses to the jcifs.smb.Handler class.
>
> In addition to the patch (which was developed against JCIFS 1.3.14), I've
> included a JUnit 4 Parameterized test that exercises many more examples of
> the problem.  We used the JUnit test class to validate that our patch
> works.  It's easy to add additional tests, so if there is any inputs that
> you think we should test (to make sure that our patch doesn't break any
> existing functionality), let us know and we'll add them.
>
> Regards,
>
> Jim Hurne | Software Engineer
> Office: +1.412.422.2499 | Mobile: +1.724.683.1500
> 1710 Murray Avenue, Pittsburgh PA 15217 USA
> hurne at vivisimo.com | Connect: www.vivisimo.com
> Vivisimo - Information Optimized
>



-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list