[jcifs] [PATCH] SmbFile URLEncoder.encode of list*() Results [was Plusses , again.]

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Thu Jan 24 14:27:20 EST 2002


This patch fixes the URL encoding issue described in the recent thread (I think :).
Nice catch Rob.

Incedentally, as long as I have this oportunity, the official way to send a patch is to
do something like:

  $ cp -r jcifs_0.6b8 jcifs_0.6b8.orig
  <make your changes>
  $ diff -Naur jcifs_0.6b8.orig/src/jcifs/smb/SmbFile.java jcifs_0.6b8/src/jcifs/smb/SmbFile.java

By using -Naur we get some context lines around each modification. If you specify
the original unmodifed source file first the + (add the line) and - (remove the line)
symbols make sense too. Finally, put [PATCH] in the subject with something
very brief about what it does. If it's more than a 10 liner you might also attach it for
good measure.

Anyone can apply this now with:

  $ patch -p0 < foo.patch

This is how, for example, patches would be submitted to the Samba mailing list.

Mike

--- jcifs_0.6b8.orig/src/jcifs/smb/SmbFile.java	Sat Jan 12 16:37:39 2002
+++ jcifs_0.6b8/src/jcifs/smb/SmbFile.java	Wed Jan 23 21:45:49 2002
@@ -26,6 +26,7 @@
 import java.net.MalformedURLException;
 import java.net.UnknownHostException;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -407,15 +408,17 @@
 		} else if( parent.canonicalPath == null ) {
 			server = parent.server;
 			share = parent.share;
+			uncPath = "\\" + name;
+			name = URLEncoder.encode( name );
 			canonicalPath = name;
 			url = parent.url + "/" + name;
-			uncPath = "\\" + name;
 		} else {
 			server = parent.server;
 			share = parent.share;
+			uncPath = parent.uncPath + "\\" + name;
+			name = URLEncoder.encode( name );
 			canonicalPath = parent.canonicalPath + "/" + name;
 			url = parent.url + "/" + name;
-			uncPath = parent.uncPath + "\\" + name;
 		}
 
 		authInfo = parent.authInfo;
@@ -1021,7 +1024,7 @@
 					continue;
 				}
 			}
-			results[j++] = filename;
+			results[j++] = filename; // URLEncoder?
 		}
 
 		/* only difference between first2 and next2
@@ -1049,7 +1052,7 @@
 						continue;
 					}
 				}
-				results[j++] = filename;
+				results[j++] = filename; // URLEncoder?
 			}
 		}
  <<jcifs_0.6b8.patch>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jcifs_0.6b8.patch
Type: application/octet-stream
Size: 1293 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20020123/1e785382/jcifs_0.6b8.obj


More information about the jcifs mailing list