I have created an System.Net.HttpListener
-based WebDav server to provide access to a(n existing) document library stored in a database through a virtual file system. The purpose of this component is to provide a file-level access to the stored documents which can be attached as a network drive under Windows, so using a different client is out of the question.
The database stores the documents in a file system-like hierarchy, so I mapped the containers as WebDav collections (which in clients show up as folders), and everything seemed nice until I found out my users use collections which has trailing periods in their names. Please note, that this is a product which is in production for more than a decade, so introducing new naming conventions is out of the question. Since HttpListener uses the standard C# System.Uri
class to provide the request URL, and that class swallows trailing periods of URLs.
https://www.something.com/xyz.
for example becomes
https://www.something.com/xyz
It would be bad enough in itself, but it could be solved by also checking for the period-extended folder name. But the problem is a lot worse than that, because the System.Uri
class does not only mutilates the last segment of the path, but all of them, so
https://www.something.com/xyz./knm/xxx.doc
becomes
https://www.something.com/xyz/knm/xxx.doc
and
https://www.something.com/xyz./knm/./qwe./xyz.doc
becomes
https://www.something.com/xyz/knm/qwe/xyz.doc
which I have no way to handle.
what I have tried so far...
- Escaping the period by replacing it with "%2E" doe not work, because it doesn't get unescaped in clients like Windows Explorer and Total Commander.
- Returning an escaped version in the PROPFIND href node and a literal version in the dislpayname node does not work, because "displayname" is ignored by most clients.
- The workaround described in this answer doesn't seem to work. (It doesn't do anything. Another answer in the same thread provides a way to hack a certain instance of the
System.Uri
class, but since the instance is created by the HttpListener - or one of its underlying mechanisms - that really does no help for me.)
In a thread from like 2008 I have found the following quote
This is a known bug. This was actually discussed on these forums not too long ago. An MSFT employee acknowledged the problem and stated that it will be considered for a future release.
Can anybody provide a workaround or actual solution to this problem?