Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 characters have the wrong encoding when using OMEMO #1187

Closed
allo- opened this issue Sep 8, 2018 · 10 comments

Comments

@allo-
Copy link

commented Sep 8, 2018

In converse.js I see UTF-8 characters (e.g. ü) from apps like Conversations or gajim as two bytes like ü and in Conversations I see for such characters sent via Conversations.

The page includes:

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@allo-

This comment has been minimized.

Copy link
Author

commented Sep 8, 2018

This happens only with OMEMO enabled.

@allo- allo- changed the title UTF-8 characters have the wrong encoding UTF-8 characters have the wrong encoding when using OMEMO Sep 8, 2018

@allo-

This comment has been minimized.

Copy link
Author

commented Sep 8, 2018

I managed to fix it by modifying the arrayBuffer <-> string methods:

  u.arrayBufferToString2 = function (ab) { 
    return new TextDecoder("utf-8").decode(ab);
  };
  u.stringToArrayBuffer2 = function (string) {
    const bytes = new TextEncoder("utf-8").encode(string)
    return bytes.buffer;
  };

Now it seems to work for me. I guess you need to implement it with a API which is supported by more/older browsers as well.

@allo-

This comment has been minimized.

Copy link
Author

commented Sep 8, 2018

When I look at the libsignal docs: Does the api even need conversion?

Type:  ByteBuffer | ArrayBuffer | Uint8Array | String
@jcbrand

This comment has been minimized.

Copy link
Member

commented Sep 10, 2018

Thanks, unfortunately TextDecoder/TextEncoder is not implemented in Edge.

https://caniuse.com/#search=textdecoder

@jcbrand jcbrand added the bug label Sep 10, 2018

@jcbrand

This comment has been minimized.

Copy link
Member

commented Sep 10, 2018

This might be a solution: https://github.com/dcodeIO/bytebuffer.js

@jcbrand

This comment has been minimized.

Copy link
Member

commented Sep 25, 2018

Does the api even need conversion?

We don't just encrypt with libsignal, the browser's builtin crypto is used to encrypt the actual message and then they keys that were generated to do that are encrypted by libsignal.

@jcbrand

This comment has been minimized.

Copy link
Member

commented Oct 1, 2018

Fixed in master, will be included in the next release.

@jcbrand jcbrand closed this Oct 1, 2018

@sleeksorrow

This comment has been minimized.

Copy link

commented Oct 2, 2018

With rev 45643d5 I am not able to write encrypted messages. Receiving client running "Conversations" just does not show any new message. Receiving Client running Pidgin with Lurch is showing: "There was an error decrypting an OMEMO message addressed to this device. See the debug log for details." Lurch debug log shows "failed to decrypt payload (-10020)"

Reverted to 4.0.0 to make basic sending work again

Edit: Did not do any bisecting. Any change between Tag 4.0.0 and HEAD can be the culprit, not necessarily the change to fix this bug

@jcbrand jcbrand reopened this Oct 2, 2018

@jcbrand

This comment has been minimized.

Copy link
Member

commented Oct 2, 2018

@sleeksorrow thanks for reporting, I'll look into it

@jcbrand

This comment has been minimized.

Copy link
Member

commented Oct 2, 2018

I did a git bisect and found that the offending commit is this one: e05b7e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.