Bug when deleting files in site recycle bin (user view)

Highlighted
Contributor

We had few times users reporting that they could not delete files from the recycle bin with the error "Values does not fall within the expected range".

 

This time I looked more in detail on one site, and I quickly suspected an issue with character escaping as the files not deleted were all having a single quote (or apostrophe) in the file name.

 

So I had a look at the XHR POST request and I saw an error 400 bad request.

 

For example, we have one file with the name "Auditor's reports.docx" (I removed a part of the name as it is confidential). The POST request endpoint URI is as bellow and we can see that the single quote as been replaced with twice "%27".

 

 

/_api/web/GetRecycleBinItemsByQueryInfo(itemState=@a1,ShowOnlyMyItems=@a2,rowLimit=@a3,pagingInfo=@a4)/GetById(@a5)/MoveToSecondStage?@a1=1&@a2=false&@a3=1&@a4='id=65a6ba57%2D7e41%2D40ed%2D9686%2Dae7a65e7cae7&title=Auditor%27%27s%20reports%2Edocx'&@a5=guid'65a6ba57-7e41-40ed-9686-ae7a65e7cae7'

When I decode the URL, I end up with 2 single quotes in the file name.

 

/_api/web/GetRecycleBinItemsByQueryInfo(itemState=@a1,ShowOnlyMyItems=@a2,rowLimit=@a3,pagingInfo=@a4)/GetById(@a5)/MoveToSecondStage?@a1=1&@a2=false&@a3=1&@a4='id=65a6ba57-7e41-40ed-9686-ae7a65e7cae7&title=Auditor''s reports.docx'&@a5=guid'65a6ba57-7e41-40ed-9686-ae7a65e7cae7'

So I edited and resent the request remove one "%27" and I was then able to remove the file. I don't really think it's a problem with the API, most likely this is an issue in the JS code when forming the request URI, as id and title are between single quote also.

 

Another fix is it to remove "pagingInfo=@a4" from GetRecycleBinItemsByQueryInfo and remove the whole "@4=" in the query string. But I guess this is here for some good reason :)

 

I also looked at the request when deleting files as admin, and the POST request is much simpler, only the guid of the file is used.

 

/_api/site/RecycleBin(@a1)/MoveToSecondStage?@a1=guid'24e9e3b7-a933-46b2-910d-09e5f688e48f'

I'm not sure if it's a known issue or not, I guess it must have happened to other tenants. However, I've seen that months ago already. This issue is present with IE, Chrome and FF.

 

I don't really want to deal with the support, so I'm posting this here, and hopefully it will be added to the SharePoint devs' backlog.

0 Replies