[jcifs] smbfolder.listFiles(SmbFileFilter) drops folders with a leading whitespace

Craig Stires craig.stires at gmail.com
Sat Jul 31 09:25:01 MDT 2010


mike, this can be scratched from the todo list


updating on this again.  i am back working at the site where there are a
number of files and folders with leading whitespaces


my initial guess that spaces were being trimmed in jcifs code was wrong.  

the problem lies with the java.net.URL constructor.  it gets rid of leading
and trailing whitespace


java.net.URL  (lines: 506-512)


   limit = spec.length();

   while ((limit > 0) && (spec.charAt(limit - 1) <= ' ')) {

      limit--;   //eliminate trailing whitespace


   while ((start < limit) && (spec.charAt(start) <= ' ')) {

      start++;   // eliminate leading whitespace




so, short of modifying the code for URL or patching the code at SmbFile
(line 620), where the URL is instantiated, i'm not sure any other path


if anyone has a suggestion, i'd most appreciate it





From: Craig Stires [mailto:craig.stires at gmail.com] 
Sent: Friday, 4 June 2010 10:59 PM
To: 'jcifs at lists.samba.org'
Subject: smbfolder.listFiles(SmbFileFilter) drops folders with a leading



wanted to followup with an update on an issue i had found in January.
hopefully, this will help isolate the problem


I'm using jcifs 1.3.14


The problem happens whenever a folder name starts with a ' '.  When
smbfolder.listFiles(SmbFileFilter) is called on a folder containing
subfolders with leading spaces, the SmbFile[] list returned has the leading
space stripped off.



actual   >  smb://mysrv/user/c/ foldername/

returned >  smb://mysrv/user/c/foldername/


I traced it down through the send stack 

(SmbFile.send(ServerMessageBlock request, ServerMessageBlock response)  

-> SmbTransport.send(request, response)


beyond that, i think it may be caused by a String.trim() further on in this

(Handler.java > getDefaultStreamHandler : 114)

   String provider = tokenizer.nextToken().trim();   // Does this need to be


other files that have a call to trim, but i'm not sure are relevant to this

   src/jcifs/dcerpc/Dcerpc/DcerpcHandle > parseBinding : 72,82,85

   src/jcifs/UniAddress > constructor : 95

   src/jcifs/http/NtlmHttpURLConnection > attemptNegotiation : 511,520

   src/jcifs/netbios/NameServiceClient > constructor : 107

   src/jcifs/netbios/Lmhosts > populate : 86,109



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20100731/86785372/attachment.html>

More information about the jCIFS mailing list