nextcloud / integration_onedrive

🗔 Integration of Microsoft OneDrive into Nextcloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong URL encoding causes failure to load any data below folders with a space in their name

n-stein opened this issue · comments

Like many here I noticed that many of my files failed to import, and while investigating I found my Nextcloud logs were being spammed with 404 errors while the app was trying to retrieve the children of my OneDrive folders.

It appears the PHP urlencode function generates application/x-www-form-urlencoded strings but HTTP requests require percent encoding in the path fragment. This causes issues when a folder name contains a space.

For example:

using urlencode the folder '/test/test folder' will become 'https://graph.microsoft.com/v1.0/me/drive/root:%2Ftest%2Ftest+folder:/children' which generates a 404 Not Found error

using rawurlencode produces the correct percent encoded string 'https://graph.microsoft.com/v1.0/me/drive/root:%2Ftest%2Ftest%20folder:/children'

I modified the lib/Service/ OnedriveStorageAPIService.php file simply replacing urlencode with rawurlencode in my own install. All of the 404 errors immediately disappeared and I received a huge influx of files that had never synced before.

I suspect this is the cause of many peoples' reported incomplete imports.

Thank you. Just updated the PHP file based on your PR in my container and the import was able to continue

EDIT : was to fast in my comment. It unlocked some files but not all. Still have to investigate for others