Closed Gareth064 closed 1 year ago
Thanks for reporting this @Gareth064, I'll have a look and let you know
@Gareth064 : You've found a bug: when the input string already contains %20 the encoding goes wrong (see below). Problem is fixed and will appear in the next nightly (version 1.8.79+) but you can also easily workaround by adding .Replace("%20", " ")
on the method input. Closing the issue, please re-open or create a new one in case the problem persists.
string serverRelativeUrl = "/sites/prov-1/I have%20SPaces/CV%20Caro%20Jansen%20r0846424%20.pdf";
string encodedServerRelativeUrl = WebUtility.UrlEncode(serverRelativeUrl.Replace("'", "''")/*.Replace("%20", " ")*/).Replace("+", "%20");
Console.WriteLine(encodedServerRelativeUrl);
//with fix, works: %2Fsites%2Fprov-1%2FI%20have%20SPaces%2FCV%20Caro%20Jansen%20r0846424%20.pdf
//without fix, fails: %2Fsites%2Fprov-1%2FI%20have%2520SPaces%2FCV%2520Caro%2520Jansen%2520r0846424%2520.pdf
@jansenbe Thank you very much for you're quick response and fix. Very much appreciated. And as you suggested, the workaround has worked a treat.
Category
Describe the bug
When trying to get a document using it's ServerRelativeUrl, and part of the Url path includes a space character, I get an error saysing the document couldn't be found.
Steps to reproduce
Results in exception
Expected behavior
A document is found and returned
Environment details (development & target environment)
Additional context
You can see that the path to the document includes a Document Library named "Customer Account" which has a space in it. I believe this is what is causing the issue. If I replicate this with a document library name "CustomerAccount", without the space, then it returns fine.