Thursday, July 16, 2015

SharePoint Double Encoding Space in URL to %2520 - An Easy Solution

I got bit by SharePoint double-encoding a %20 (space) in a list name when I tried to rename a customized display form used in that list.

Now, mind you, these are two things I always avoid - spaces in list names and customized forms. But I inherited these, and then I proceeded to muck it up with the rename. The result was that links on tasks that went back to the list were double encoded - the % in %20 becomes an incredibly insidious %25, which is just a horrible thing in a web browser.

Now you might want to try some simple workaround or fix, like a redirect or something, but touching that %25 is real hard. I found a great solution using jQuery to rewrite the URLs. I did not try this but it seemed like it would work.

I found that if I renamed the list without any characters to encode, the links were all fixed.

Next I wanted to put the list back to the original name. This turned out to be impossible. No matter how I did this, SharePoint was nice enough to double encode the thing and make it %2520.

So the answer is to permanently change the URL for the list to not have any encoded characters (spaces, etc.). If need be, you could do some sort of redirect for anything with the old name, but this is largely unnecessary as SharePoint really does a good job with fixing all the URLS (just as it broke some of them).

No comments:

Post a Comment