[jcifs] Creating file with hash ('#') in filename

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Thu Jan 16 13:03:09 EST 2003

> -----Original Message-----
> From:	Christopher R. Hertel [SMTP:crh at ubiqx.mn.org]
> > The java.net.URL class parses the URL and *before* the jcifs.smb.Hanlder
> > gets it. So the '#ref' is getting picked out. I was just saying perhaps
> > I can append it back on to create an internal path that retains it.
> Only if you want to bypass the standard syntax for URLs.  :)
	You mean HTTP URLs. It's the HTTP URL that uses '#'. We don't have any
	use for it.

> The # (if unescaped) in that position should be a delimiter and the
> pedantic way to handle it is to cough back an error.
	For HTTP URLs. For SMB URLs this remains to be seen. We cannot
	conform to the HTTP URL closely without a cost. The main problem is that
	SMB path names need to represent just about any character including
	Unicode which we haven't even touched on. I personally do not want to
	decode paths. That is very costly. It is very likely that SMB URLs will contain
	reserved characters like space, '@', and '#'. We cannot accept both encoded
	and non encoded URLs because URLs returned by jCIFS will need to be
	encoded. Even if you pass back whatever was passed in how do you handle
	URLs derived from a parent during a list() operation. It get's very messy. Can
	someone give me a reason why we *have* to require URL encoding of the
	path component? Otherwise I think we should punt the '#ref' and just integrate
	it into the path. Anything we would use it for can be done with a query_string

	Incedentally speaking of query_string parameters we got lucky with the '?'
	character. That *is* reserved in SMB pathnames. It's a wildcard character.
	Otherwise we really *would* have to require escaping path components.

	Anyway it looks like just tacking the '#ref' back onto the path component in
	Handler.java is going to do the trick. NetworkExporer doesn't like it but that's
	because the SMB URLs are going through the browser as part of the path. In
	this case they *are* HTTP URLs and as such need to be escaped. I'll leave
	the NetworkExplorer fixes till later I think.

More information about the jcifs mailing list