From f98b0642c91f1685a0eebc0f7d3f45421ba1785a Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 11 Feb 2021 09:23:22 -0500 Subject: [PATCH] fix profile export / import to support utf8 / unicode --- app.js | 1 + package.json | 1 + src/kiri/main.js | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 461487ac..81d9e24b 100644 --- a/app.js +++ b/app.js @@ -246,6 +246,7 @@ const script = { "ext/tween", "ext/fsave", "ext/earcut", // work.test + "ext/base64", "add/array", "add/three", "geo/base", diff --git a/package.json b/package.json index 1421b026..f124c378 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "slicer" ], "dependencies": { + "base64-js": "^1.5.1", "buffer-crc32": "^0.2.13", "compression": "^1.7.4", "connect": "^3.7.0", diff --git a/src/kiri/main.js b/src/kiri/main.js index 279ec9c3..253b3449 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -2194,7 +2194,7 @@ function settingsImport(data, ask) { if (typeof(data) === 'string') { try { - data = JSON.parse(atob(data)); + data = JSON.parse(new TextDecoder().decode(base64js.toByteArray(data))); } catch (e) { UC.alert('invalid settings format'); console.log('data',data); @@ -2269,7 +2269,7 @@ const shot = opts.work || opts.screen ? SPACE.screenshot() : undefined; const work = opts.work ? KIRI.codec.encode(WIDGETS,{_json_:true}) : undefined; const view = opts.work ? SPACE.view.save() : undefined; - return btoa(JSON.stringify({ + return base64js.fromByteArray(new TextEncoder().encode(JSON.stringify({ settings: settings, version: KIRI.version, screen: shot, @@ -2280,7 +2280,7 @@ moto: MOTO.id, init: SDB.getItem('kiri-init'), time: Date.now() - })); + }))); } function platformLoadFiles(files,group) {