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


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".




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.



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