Rayquaza01 / authenticator

Firefox addon that generates TOTPs for 2 factor authentication
https://addons.mozilla.org/en-US/firefox/addon/two-factor-authenticator/
MIT License
34 stars 7 forks source link

Extras / Import -- Bug + proposed solution #19

Closed vlc33 closed 5 years ago

vlc33 commented 6 years ago

Hello I use Extra / Export to get my topt.json, it works.

But then I delete all entries and try to get Extra / Import of the saved file, but nothing happens I have to retype all entries mannually.

I just examined the topts.json file and found a solution replacing a regex as follows /,"fontColor":"$/}/

It works but the solution inside the code I do not know how to do it.

Thank You.

Please fill out this information:

Rayquaza01 commented 6 years ago

Hello, Thank you for pointing this out. It's the same issue in Rayquaza01/note-taker#14

So, a data URL is used to create the export. The URL looks something like data:application/json;charset=utf-8,{"fontColor":"#000000"}. If you open that URL, you'll see SyntaxError: JSON.parse: unterminated string literal at line 1 column 15 of the JSON data. This is because # causes data URLs to end early. This can be fixed by running encodeURIComponent on the export data to get a URL like data:application/json;charset=utf-8,%7B"fontColor"%3A"%23000000"%7D, which will work correctly.

Rayquaza01 commented 5 years ago

Fixed in 1.3.1