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

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

Closed
Unkn0wnCreator opened this issue Dec 22, 2022 · 5 comments · Fixed by #23
Closed

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

Unkn0wnCreator opened this issue Dec 22, 2022 · 5 comments · Fixed by #23

Comments

@Unkn0wnCreator
Copy link

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?

@mprimi
Copy link
Owner

mprimi commented Dec 22, 2022

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.

TeddyBear06 added a commit to TeddyBear06/portable-secret that referenced this issue Dec 25, 2022
Fixes mprimi#7 using a Blob rather than btoa (as btoa() creates a Base64-encoded ASCII string).

Side modifiation, the {{VALUES}}\n substitution does not works on my environnement as the substituion is searching for a litteral \n in the template. Feel free to remove this modification if it's not relevant and I juste missed something along the way :-)
@gamedevsam
Copy link

Is this fixed?

@TeddyBear06
Copy link
Contributor

TeddyBear06 commented Jan 8, 2023

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.

@mprimi
Copy link
Owner

mprimi commented Jan 10, 2023

@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.

@TeddyBear06
Copy link
Contributor

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.

mprimi pushed a commit that referenced this issue Jan 11, 2023
Fixes #7 using a Blob rather than btoa (as btoa() creates a Base64-encoded ASCII string).

Side modifiation, the {{VALUES}}\n substitution does not works on my environnement as the substituion is searching for a litteral \n in the template. Feel free to remove this modification if it's not relevant and I juste missed something along the way :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants