lib/rest: process HTML entities within XML#5848
Conversation
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.
|
What do you think the backwards compatibility problems with this patch might be given that the jottacloud and sugarsync backends use the XML parser in lib/rest as well as the webdav backend. Does this need to be an option? |
|
Great question! I did notice that those backends use this function too, and indeed was concerned about breaking them. I didn't address it initially because I deemed the act of processing HTML entities to be a "non-destructive" action, particularly as the alternative is the parser throwing an error. If you think it would be wiser to restrict this to webdav, I could make it an option. After all, there's no reason why those two services should start acting out of specification, compared to the larger amount of WebDAV software. |
|
Here are the docs: https://pkg.go.dev/encoding/xml#Decoder The first fix seems OK and unlikely to cause a problem. The second fix - means that the parse would have thrown an errror rather than leave the undecodable entities according to the source code, so that is OK too. The second part of your patch is So I think, on further reflection, this patch is safe and won't break anything. We'll see soon enough in the integration tests and if it does cause a problem we'll need to make it conditional. So I'll merge this now - thank you :-) |
|
PS since you are interested in using mega with webdav, would you like to write some docs in the webdav backend for it? Or maybe we could make a webdav provider for it? Possibly rclone could even start/stop the mega process. |
|
Sure, I can think about what I could do ^^ |
What is the purpose of this change?
The MEGA SDK - and, by extension, MEGAcmd - escapes many HTML entities in the XML it serves as the WebDAV server. This is not conformant XML, and I have already submitted a PR to fix this. That having been said, I am submitting a fix for rclone too for a couple of reasons:
megabackend currently has an issue (Mega.nz Session Cache #4695) that makes it difficult to use, making this WebDAV functionality useful.For reference, this is what currently happens when using a problematic filename with MEGAcmd's WebDAV server, and rclone:
Was the change discussed in an issue or in the forum before?
Most directly, this issue is reported here and in #4885. The "rather strict" XML parser is also discussed in this comment.
Checklist
Thanks!