OneDrive / onedrive-api-docs

Official documentation for the OneDrive API
MIT License
447 stars 228 forks source link

ODP | ODB: OneDrive API sends HTML characters as part of JSON response #1765

Open abraunegg opened 6 months ago

abraunegg commented 6 months ago

Category

Expected or Desired Behavior

The API should not send HTML characters in JSON response

Observed Behavior

In tracking down why a OneDrive Personal Shared Folder will not sync, it has been determined that the technical reason is not code, but that the OneDrive API sends the path with HTML characters embedded in the JSON response:

[DEBUG] ------------------------------------------------------------------
[DEBUG] Existing Microsoft OneDrive Access Token Expires: 2023-Dec-19 13:17:45.2953313
[DEBUG] Request URL = https://graph.microsoft.com/v1.0/drives/f3028bd758552faf/items/F3028BD758552FAF!4690/delta
[DEBUG] API Response Bundle: 1 - Quantity of 'changes|items' in this bundle to process: 201
[DEBUG] ------------------------------------------------------------------
[DEBUG] Processing OneDrive Item 1 of 201 from API Response Bundle 1
[DEBUG] Raw JSON OneDrive Item: {"@odata.type":"#microsoft.graph.driveItem","cTag":"adDpGMzAyOEJENzU4NTUyRkFGITQ2OTAuNjM4Mzg1NjkyMTA1MTcwMDAw","createdBy":{"application":{"id":"481710a4"},"user":{"displayName":"Redacted Redacted","id":"9ba6f07668ba1ff7"}},"createdDateTime":"2023-11-06T20:37:13.387Z","eTag":"aRjMwMjhCRDc1ODU1MkZBRiE0NjkwLjI","fileSystemInfo":{"createdDateTime":"2023-11-06T20:37:13.386Z","lastModifiedDateTime":"2023-11-06T21:09:58.813Z"},"folder":{"childCount":0,"view":{"sortBy":"name","sortOrder":"ascending","viewType":"thumbnails"}},"id":"F3028BD758552FAF!4690","lastModifiedBy":{"application":{"id":"481710a4"},"user":{"displayName":"Redacted Redacted","id":"9ba6f07668ba1ff7"}},"lastModifiedDateTime":"2023-12-19T07:53:30.517Z","name":"OneDrive - Redacted","parentReference":{"driveId":"f3028bd758552faf","driveType":"personal","id":"F3028BD758552FAF!313","name":"Dokumente","path":"\/drives\/f3028bd758552faf\/items\/F3028BD758552FAF!313:"},"shared":{"owner":{"user":{"displayName":"Redacted Redacted","id":"f3028bd758552faf"}},"scope":"users","sharedDateTime":"2023-11-06T20:38:29.8602153Z"},"size":6224611033,"webUrl":"https:\/\/1drv.ms\/f\/s!AK8vVVjXiwLzpFI"}
[DEBUG] This item is not a OneDrive deletion change
[DEBUG] defaultRootId                                        = 9BA6F07668BA1FF7!103
[DEBUG] 'search id'                                          = F3028BD758552FAF!4690
[DEBUG] id == defaultRootId                                  = false
[DEBUG] isItemRoot(onedriveJSONItem)                         = false
[DEBUG] onedriveJSONItem['name'].str == 'root'               = false
[DEBUG] itemHasParentReferenceId                             = true
[DEBUG] sync_list item to check: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive - Redacted
[DEBUG] Evaluation against 'sync_list' for this path: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive - Redacted
[DEBUG] [S]exclude           = false
[DEBUG] [S]exludeDirectMatch = false
[DEBUG] [S]excludeMatched    = false
[DEBUG] Evaluation against 'sync_list' entry: OneDrive - Redacted
[DEBUG] [F]exclude           = false
[DEBUG] [F]exludeDirectMatch = false
[DEBUG] [F]excludeMatched    = false
[DEBUG] Evaluation against 'sync_list' final result: EXCLUDED
Skipping item - excluded by sync_list config: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive - Redacted
[DEBUG] ------------------------------------------------------------------
[DEBUG] Processing OneDrive Item 2 of 201 from API Response Bundle 1
[DEBUG] Raw JSON OneDrive Item: {"@odata.type":"#microsoft.graph.driveItem","cTag":"adDpGMzAyOEJENzU4NTUyRkFGITQyNTAuNjM4MzQ5MDA2OTQyMTcwMDAw","createdBy":{"application":{"id":"480728c5"},"device":{"id":"188009f993dc5a"},"user":{"displayName":"Redacted Redacted","id":"f3028bd758552faf"}},"createdDateTime":"2023-03-06T16:00:36.51Z","eTag":"aRjMwMjhCRDc1ODU1MkZBRiE0MjUwLjI","fileSystemInfo":{"createdDateTime":"2023-03-06T16:00:36.51Z","lastModifiedDateTime":"2023-11-06T20:40:17.653Z"},"id":"F3028BD758552FAF!4250","lastModifiedBy":{"user":{"displayName":"Redacted Redacted","id":"9ba6f07668ba1ff7"}},"lastModifiedDateTime":"2023-11-06T20:51:34.217Z","name":"Notizbuch von Redacted","package":{"type":"oneNote"},"parentReference":{"driveId":"f3028bd758552faf","driveType":"personal","id":"F3028BD758552FAF!4690","name":"OneDrive - Redacted","path":"\/drives\/f3028bd758552faf\/items\/F3028BD758552FAF!313:\/OneDrive%20-%20Redacted"},"size":1344676,"webUrl":"https:\/\/1drv.ms\/o\/s!AK8vVVjXiwLzoRo"}
[DEBUG] This item is not a OneDrive deletion change
[DEBUG] defaultRootId                                        = 9BA6F07668BA1FF7!103
[DEBUG] 'search id'                                          = F3028BD758552FAF!4250
[DEBUG] id == defaultRootId                                  = false
[DEBUG] isItemRoot(onedriveJSONItem)                         = false
[DEBUG] onedriveJSONItem['name'].str == 'root'               = false
[DEBUG] itemHasParentReferenceId                             = true
[DEBUG] sync_list item to check: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive%20-%20Redacted/Notizbuch von Redacted
[DEBUG] Evaluation against 'sync_list' for this path: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive%20-%20Redacted/Notizbuch von Redacted
[DEBUG] [S]exclude           = false
[DEBUG] [S]exludeDirectMatch = false
[DEBUG] [S]excludeMatched    = false
[DEBUG] Evaluation against 'sync_list' entry: OneDrive - Redacted
[DEBUG] [F]exclude           = false
[DEBUG] [F]exludeDirectMatch = false
[DEBUG] [F]excludeMatched    = false
[DEBUG] Evaluation against 'sync_list' final result: EXCLUDED
Skipping item - excluded by sync_list config: drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive%20-%20Redacted/Notizbuch von Redacted
[DEBUG] ------------------------------------------------------------------

The respective item to look at is the following:

    "parentReference": {
        "driveId": "f3028bd758552faf",
        "driveType": "personal",
        "id": "F3028BD758552FAF!4690",
        "name": "OneDrive - Constanze",
        "path": "/drives/f3028bd758552faf/items/F3028BD758552FAF!313:/OneDrive%20-%20Redacted"
    },
    "size": 1344676,
    "webUrl": "https://1drv.ms/o/s!AK8vVVjXiwLzoRo"
}

Here, the 'path' element now contains %20 where as the previous JSON item as part of the /delta query did not contain any %20 HTML characters

Steps to Reproduce

Unsure - as the OneDrive API should not be sending HTML characters embedded as part of the JSON response.