[jcifs] Has anybody else seen problems with file names that start with a dot?

Michael B Allen mba2000 at ioplex.com
Mon Nov 10 11:19:26 EST 2003

> Reproduced.
> I think it has to do with SMB URL handling...

Actually this appears to be just poor parsing on the part of the
java.net.URL class. Unfortunately I don't think we cannot write our own
parser and support java.net.URL at the same time because of the way the
protocol handlers work.

The below test program illustrates the problem:

$ cat HttpURL.java
import java.net.*;

public class HttpURL {

        public static void main( String[] args ) throws Exception {
                URL u = new URL( new URL( args[0] ), args[1] );
                System.out.println( u );

$ java HttpURL "http://server/apath/" "filename.txt"
$ java HttpURL "http://server/apath/" ".filename.txt"
$ java HttpURL "http://server/apath/" ".a#filename.txt"
$ java HttpURL "http://server/apath/" ".#filename.txt"
http://server/apath/#filename.txt           <-----OOPS
$ java HttpURL "http://server/apath/" "..#filename.txt"
http://server/#filename.txt                 <----WORSE
$ java HttpURL "http://server/apath/" "...#filename.txt"

Currently I don't think I can take this problem further and can only
recommend that you avoid this particular class of filenames.

Hopefully the java.net.URI class is better...


> On Thu, Nov 06, 2003 at 08:06:47PM -0500, Marc Savereux wrote:
>> Hello Christopher,
>>    Here's a program that will demonstrate the problem, however, I have
>> to
>> correct myself in that the symbol that follows the dot does matter, and
>> in
>> fact .profile works but .#AboutJShell.java will not, it will simply drop
>> the
>> dot in that case. The fonts onscreen, made it look like there was a
>> space
>> instead of the missing dot, but using a monospaced font confirmed
>> otherwise.
>>    Here's the output from the test program.
>> URL      : smb://
>> Username : SMBTEST
>> Password : SMBTEST
>> [smb://] is a directory...
>> Listing the contents of directory using .list() method.
>> .#AboutJShell.java
>> .profile
>> Icon
>> Network Trash Folder
>> pfaro
>> Listing the contents of directory using .listFiles() method.
>> smb://
>> smb://

A program should be written to  model the concepts of the task it
performs rather than the physical world or a process because this
maximizes the  potential for it  to be applied  to tasks that are
conceptually similar and, more  important, to tasks that have not
yet been conceived.

More information about the jcifs mailing list