flymzero / webdav_client

A dart WebDAV client library
https://pub.dev/packages/webdav_client
BSD 3-Clause "New" or "Revised" License
54 stars 34 forks source link

Encode the pound/hash/number symbol (#) #48

Open Ansis100 opened 2 months ago

Ansis100 commented 2 months ago

The URL code for # is %23. When a WebDAV server receives a URL containing a literal #, it ignores everything after the symbol (e.g. http://host.com/file#1234.txt becomes http://host.com/file), presumably because # is reserved for HTML anchors.

Now, webdav_client uses Uri.encodeFull to encode URLs. From the docs:

All characters except uppercase and lowercase letters, digits and the characters !#$&'()*+,-./:;=?@_~ are percent-encoded.

This means that if any method from webdav_client receives a file path containing the symbol #, it will not encode it and the server will receive a truncated request URL, which results in unexpected behaviour.

Ansis100 commented 2 months ago

Only just now realized that this is a duplicate of #47 (after running it through Google Translate). I'd suggest keeping it open so others don't make the same mistake as me.

flymzero commented 2 months ago

Some defects will be fixed or refactored in the later stage. At present, I am busy. Thank you very much