mprimi / portable-secret

Better privacy without special software

Home Page:https://mprimi.github.io/portable-secret/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] The generated secret.html file does not support UTF-8 chars

Unkn0wnCreator opened this issue · comments

Hi,

When I use chars like the german-umlaute "öäü" they will get Replaced with ���

Maybe the secret.html is exported with ASCII encoding and not UTF-8 so that the chars are lost when JS is handling them?

I'm not a web developer, this is one quirk of Javascript I have not had time to fight with and tame.

The btoa() method creates a Base64-encoded ASCII string from a binary string

Except if the string contains unicode, then btoa() chokes on it.

Probably related to that.

I'll eventually get around to look into it and fix it.

Is this fixed?

commented

Is this fixed?

I did fork the project and fix it (see: https://github.com/TeddyBear06/portable-secret) but the maintainer won't merge as stated here (and we all understand why 😇): #29.

Working live version: https://lfconsult.fr/portable-secret/index.html

Generate
Decrypt

Feel free to use my fork/fix.

@TeddyBear06 is the change to blob you proposed (https://github.com/mprimi/portable-secret/pull/23/files) sufficient to handle these non-ascii characters? Because if so I'm inclined to take your change.

commented

Hey @mprimi

Short answer: Yep.

Long answer: Blobs aren't "encoding aware" (it's just raw binary data after all). The Blob will store the supplied content "as is" and spit it out when we call window.URL.createObjectURL(blob) (what btoa() doesn't as it expects caracters that only occupy less than 1 byte, see: https://developer.mozilla.org/en-US/docs/Web/API/btoa#unicode_strings). As the target HTML file is correctly declared as an UTF-8 encoded document, UTF-8 caracters are handled as expected.

I hope I'm not missing something along the way but, that's the whole idea.