From 1d4c13c798639c925825c70150b138553f8dff49 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 5 Sep 2016 00:49:36 +0100 Subject: Fix megolm decryption of UTF-8 Repeat the fix from b10f90d for megolm messages. It turns out that the 'length' argument to 'Pointer_stringify' doesn't work if the input includes characters >= 128. Rather than try to figure out which methods can return UTF-8, and which always return plain ascii, replace all uses of Pointer_stringify with a 'length' argument with the version that expects a NULL-terminated input, and extend the buffer by a byte to allow space for a null-terminator. In the case of decrypt, we need to add the null ourself. Fixes https://github.com/vector-im/vector-web/issues/2078. --- javascript/olm_post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript/olm_post.js') diff --git a/javascript/olm_post.js b/javascript/olm_post.js index 955d68d..dac89f6 100644 --- a/javascript/olm_post.js +++ b/javascript/olm_post.js @@ -5,7 +5,7 @@ var Pointer_stringify = Module['Pointer_stringify']; var OLM_ERROR = Module['_olm_error'](); /* The 'length' argument to Pointer_stringify doesn't work if the input includes - * cahracters >= 128; we therefore need to add a NULL character to all of our + * characters >= 128; we therefore need to add a NULL character to all of our * strings. This acts as a symbolic constant to help show what we're doing. */ var NULL_BYTE_PADDING_LENGTH = 1; -- cgit v1.2.3