lib/rest: process HTML entities within XML

MEGAcmd currently includes escaped HTML4 entites in its XML messages.
This behavior deviates from the XML standard, but currently it prevents
rclone from being able to use the remote.
This commit is contained in:
Koopa 2021-12-01 02:15:05 -05:00 committed by Nick Craig-Wood
parent df09c3f555
commit 0681a5c86a
1 changed files with 4 additions and 0 deletions

View File

@ -167,6 +167,10 @@ func DecodeJSON(resp *http.Response, result interface{}) (err error) {
func DecodeXML(resp *http.Response, result interface{}) (err error) {
defer fs.CheckClose(resp.Body, &err)
decoder := xml.NewDecoder(resp.Body)
// MEGAcmd has included escaped HTML entities in its XML output, so we have to be able to
// decode them.
decoder.Strict = false
decoder.Entity = xml.HTMLEntity
return decoder.Decode(result)
}