Discussion:
[jcifs] URL not correctly parsed if password contains number sign ('#')
Guertler Mario
2016-02-04 14:12:03 UTC
Permalink
Hi all,

I think I found a bug in your implementation. We are using JCIFS in many applications successfully, but if the number sign ('#') is used in password then we get problems.
I already figured out where the problem is; the passed URL string of constructor 'public SmbFile(String url)' is not correctly parsed.

The following code:

String connectString ="smb://user:passwort#***@host/share/Test/";
SmbFile polledFile = new SmbFile(connectString);

Results in following field variables of class SmbFile or better of class URL

authority "user:test#***@host"
file "#***@host/share/Test/"
path "#***@host/share/Test/"
protocol "smb"
userInfo "user:test#123456789"

So you can see that the file/path is not correct und the access to this file will fail because it does not exist.

Mit freundlichem Gruß / Best regards

Mario Gürtler
Senior Engineer

znt Zentren für Neue Technologien GmbH
Institut Dresden
Am Brauhaus 12
D-01099 Dresden

Hauptverwaltung und Sitz: Lena-Christ-Str. 2, 82031 Grünwald, Amtsgericht München HRB 179019
Geschäftsführer: Bernhard Marsoner, Ulrike Birnstiel
Prokuristen: Hans Mayer, Gerhard Schrottshamer

Office: +49 351 652 480-20
Mobile:
Fax: +49 351 652 480-29
E-Mail: ***@znt.de
Web: http://www.znt-richter.com<http://www.znt-richter.com/>

[Loading Image...]
Munich | Burghausen | Dresden | Villach/Austria | Singapore | Penang/Malaysia | San Francisco/USA

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Michael B Allen
2016-02-06 20:49:33 UTC
Permalink
Post by Guertler Mario
Hi all,
I think I found a bug in your implementation. We are using JCIFS in many
applications successfully, but if the number sign (‘#’) is used in password
then we get problems.
I already figured out where the problem is; the passed URL string of
constructor ‘public SmbFile(String url)’ is not correctly parsed.
SmbFile polledFile = new SmbFile(connectString);
Results in following field variables of class SmbFile or better of class URL
protocol "smb"
userInfo "user:test#123456789"
So you can see that the file/path is not correct und the access to this
file will fail because it does not exist.
Hi Mario,

This is actually not a bug. You must URL encode any characters in a URL
that are special characters for URLs. The # sign is a ref marker. Try
substituting with %23.

However, you should not put the password in the URL in the first place.
That is only for quick and dirty things like running something once from a
commandline. The correct way to pass credentials is to create an
NtlmPasswordAuthentication object and use that with the appropriate
constructor.

Mike

Loading...