ironthree / dxr

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

Empty <value></value> is not handled correctly #9

Closed bahlo closed 1 year ago

bahlo commented 1 year ago

Sorry, I missed that case in #8. This is a valid response:

<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse><params><param>
    <value></value>
</param></params></methodResponse>

This library fails to parse that:

Response failed with: missing field `$value`; Fault failed with: missing field `fault`
decathorpe commented 1 year ago

Hm, yes, this is probably expected to be handled just like an empty string. I'm not at my PC right now, will review and merge later. Thanks!

decathorpe commented 1 year ago

Fix looks simple enough and tests pass, thanks for the PR.

Note that <?xml version="1.0" encoding="iso-8859-1"?> is technically not supported by dxr right now, since the quick-xml/encoding feature is not enabled. It should be straightforward to fix that, but the feature pulls in additional dependencies, so I'd rather hide it behind a feature flag ... what do you think?

bahlo commented 1 year ago

I feel like it‘s better to lean on compatibility and default to the encoding feature, especially since most XML-RPC servers are probably old, but I can see both sides.

I’m happy, no matter if I have to enable a feature flag or not 😁

decathorpe commented 1 year ago

PS: Reading the docs, I'm not even sure if ISO-8859-1 is supported by encoding_rs (the library that quick-xml uses for handling character encodings) ... reading https://docs.rs/encoding_rs/0.8.32/encoding_rs/index.html#iso-8859-1 didn't really help to clear things up.