ironthree / dxr

Declarative XML-RPC in Rust
Apache License 2.0
17 stars 8 forks source link

deps: update quick-xml dependency #12

Closed decathorpe closed 1 year ago

decathorpe commented 1 year ago

The quick-xml dependency is currently pinned to v0.25, while upstream has already released v0.29. However, I'm not sure how to handle some of the breaking changes since v0.25:

  1. The $text attribute (added in v0.28.0) breaks the new custom Value deserializer (though adding a case for "$text" to the match statement seems to solve that (not sure if that's correct, but it seems to work 😕)
  2. quick-xml now defaults to writing self-closing XML tags when serializing empty strings (i.e. empty string values are written as <value><string /></value> and empty bytes are written as <value><base64 /></value>. While this is valid XML and should be acceptable for XML-RPC, it's inconsistent with other implementations

I've checked how Python's xmlrpc module handles this (see below) - it supports reading XML with self-closing tags, but it does not seem to ever write them. I don't think there's a way to control this behaviour from the quick-xml serializer side (without writing a custom serializer ...)


import xmlrpc.client
xmlrpc.client.loads("<params>\n<param>\n<value><string /></value>\n</param>\n</params>\n")
# (('',), None)
xmlrpc.client.loads("<params>\n<param>\n<value><string></string></value>\n</param>\n</params>\n")
# (('',), None)
xmlrpc.client.dumps(("",))
# '<params>\n<param>\n<value><string></string></value>\n</param>\n</params>\n'
decathorpe commented 1 year ago

@bahlo You seem to have more experience with weird XML-RPC clients / servers than me - do you think it would be an issue if dxr clients / servers started sending XML-RPC messages that contained self-closing XML tags for empty strings / bytes?

decathorpe commented 1 year ago

Correction: quick-xml seems to write <string/> and <base64/> without a space before />. It looks weird to me for some reason, but it appears to be valid XML 1.0 syntax.


EDIT: https://github.com/ironthree/dxr/commit/407a3a189c7afdfab1354decf95712917f11a999 is how far I've gotten. I needed to adapt some tests for the behaviour change, but everything else still seems to work.

bahlo commented 1 year ago

Hah yeah I sadly do—the server I‘m interfacing with is using XMLRPC++ 0.7 and does not support self-closing xml tags so I‘d selfishly advise to not use that feature 🥸

decathorpe commented 1 year ago

For some reason I suspected as much 😓 I opened an issue with quick-xml upstream, maybe this can be worked around somehow: https://github.com/tafia/quick-xml/issues/617

decathorpe commented 1 year ago

quick-xml v0.30 was released with the new API.

This commit updates the dependency and adjusts the code accordingly: https://github.com/ironthree/dxr/commit/ee8799856d2eebbaad81167ccbf92c22a542bd30

Will be part of the upcoming (soon!) v0.6.0 release.

bahlo commented 1 year ago

appreciate it!