Description
- Operating System (Linux/Mac/Windows/iOS/Android):
- Core Version: v1.159.3
- Client Version: Desktop 1.57.0 (git: v1.57.0-8-g09f45d1c9)
Expected behavior
get_draft
works
Actual behavior
The draft becomes corrupted and get_draft
never succeeds until the .xdc
attachment is removed from it, or the draft itself is removed.
Additionally, misc_send_draft
also fails with anyhow: .../....xdc is not a valid webxdc file
.
Steps to reproduce the problem
- Create an empty file.
- Rename it to
foo.xdc
. - Open the messenger client
- Attach the said file. Don't sent the message.
- Switch to another chat.
- Switch back to the original chat.
You'll see that the composer is disabled, because the code does not expect that getDraft
fails.
Screenshots
Logs
Uncaught (in promise)
{code: -1, message: 'unable to locate the end of central directory record'}
Promise.then
(anonymous) @ Composer.tsx:764
(anonymous) @ Composer.tsx:797
I'm not sure whether to consider this JSON-RPC-specific, since misc_send_draft
also fails.
core/deltachat-jsonrpc/src/api.rs
Lines 2150 to 2158 in 1db9b77
I believe the error happens here
core/deltachat-jsonrpc/src/api/types/message.rs
Lines 145 to 149 in 21010f4
The Viewtype
it Webxdc
because it gets set here
Lines 927 to 937 in ef798cd
but this is only based on file extension, and not on whether the .xdc
file is actually valid.
I think we have to options here:
- In
set_draft
, check the validity of the file prior to settingViewtype::Webxdc
. - Handle the fact that
Viewtype::Webxdc
messages can still have an invalid.xdc
file, i.e. thatget_webxdc_info
can fail.
The latter seems more sensible to me, because this is similar to having an invalid image file: we'd just want to say "this is supposed to be an image, but we couldn't display it".
Related:
- fix:
fetch_url
: return err on non 2xx reponses #6814 - which fixes an issue with drafting invalid.xdc
files. However, attaching an invalid.xdc
file manually from file system is still possible.