Compartilhar via


SharePoint 2013 : The search results with %5C (the “” character) will become double encoded and causes broken links

 

Use Case Description: The search results with %5C (the “\” character) will become double encoded (represented as “%255C″). This causes broken links for e.g. when accessing Search Center and performing people search with "user1". At the peopleresults.aspx page, click the username in the search result

Actual Results: The personal site of user1 cannot be accessed. You can see the personal site for user1 is something like below

https://sp2013.contoso.com/my2/Person.aspx?accountname=contoso%255Cuser1

 

Workaround Instructions: Apply below workaround on current search center site. If you have additional search center sites, please update all of them.

1. On your Search Center site collection go to Site Settings and then Master Page Gallery

2. On Master Page Gallery click on Display Templates and then click on Search

Now find File named Item_Person.html and then checkout the file. Make a backup of the file and open the file in your favorite text editor and locate highlighted Line in below Screenshot.

 

image

3. Now replace above highlighted line replace with following text.

var encodedPath = $urlHtmlEncode(decodeURI(ctx.CurrentItem.Path));

4. Now find File named Item_Person_CompactHorizontal.html and then checkout the file. Make a backup of the file and open the file in your favorite text editor and then locate highlighted Line in below Screenshot.

image

 

5. Now replace above highlighted line replace with following text.

              var pathEncoded = $urlHtmlEncode(decodeURI(ctx.CurrentItem.Path));

 

6. Now find File named Item_Person_HoverPanel.html and then checkout the file. Make a backup of the file and open the file in your favorite text editor and then locate highlighted Line in below Screenshot.

 

image

Now replace above highlighted line so that it looks like following.

<a id="_#= visitId =#_" class="ms-calloutLink ms-uppercase" href="_#= $urlHtmlEncode(decodeURI(ctx.CurrentItem.Path)) =#_" title="_#= $htmlEncode(Srch.Res.hp_PeopleItem_ViewProfile) =#_">

7. Now check-in the above files and make sure they are published.

Note:  This issue is now fixed as described in https://support.microsoft.com/kb/2883088 , Which is included in Sep 2014 CU for SharePoint 2013

 

POST BY: Srinivas Dutta [MSFT]

Comments

  • Anonymous
    June 30, 2014
    I've provided a more global fix (as this doesn't occur with just People searches and Display Templates are Site Collection scope) available at thesharepointfarm.com/.../workaround-ms14-022-double-encoding-bug. Technically, the global fix is also easier to revert when an official fix is released.

  • Anonymous
    July 01, 2014
    Although the proposed workaround of updating JS files may work for the customers, changing the JS file will make the deployment ‘un-patchable’ in a sense and patches will not be able to update a system that has undergone such a change. Editing the OOB Javascript files is not supported by Product Support & services.

  • Anonymous
    July 02, 2014
    The comment has been removed

  • Anonymous
    July 02, 2014
    Will this affect the "Show More" link on search results where Hybrid is configured. I do see this behavior because when i search for * and click show more it is being translated into tenant.sharepoint.com/.../results.aspx.  

  • Anonymous
    August 12, 2014
    Is this issue resolved with the combination of July and August patches?

  • Anonymous
    August 17, 2014
    Good work around, Thanks, Editing OOB js was not an option for us. We use OOB search center, I resolved this by adding a Script Editor webpart to results.aspx with following script <script language="javascript"> function customSearchResultsFixUrlEncoding(str, find, replace) {  return str.replace(new RegExp(find, 'g'), replace); } $('.ms-searchCenter-result-main').on("click", "a", function (event) { var url= $(this).attr('href'); var url2 = customSearchResultsFixUrlEncoding(url, "%2520", "%20"); var url2 = customSearchResultsFixUrlEncoding(url2, "%255C", "%5C"); var url2 = customSearchResultsFixUrlEncoding(url2, "%252E", "%2E"); $(this).attr('href', url2); }); </script>

  • Anonymous
    September 17, 2014
    The comment has been removed

  • Anonymous
    September 17, 2014
    This issue has been addressed through permanent fix now. Please contact Microsoft support if you require permanent fix info.

  • Anonymous
    March 10, 2015
    Thank you SO much for providing this great fix. It works on our server and I love you for it.