From 9f52a2abfd288d4f38d3caf6221c909fb0cbed55 Mon Sep 17 00:00:00 2001 From: Carlo Piovesan Date: Thu, 14 Dec 2023 16:47:06 +0100 Subject: [PATCH] Change encoding/deconding from using atob to encodeURIComponent-based --- packages/duckdb-wasm-shell/src/shell.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/duckdb-wasm-shell/src/shell.ts b/packages/duckdb-wasm-shell/src/shell.ts index cd5ecfb19f..e5ff09cd8f 100644 --- a/packages/duckdb-wasm-shell/src/shell.ts +++ b/packages/duckdb-wasm-shell/src/shell.ts @@ -52,7 +52,7 @@ class ShellRuntime { } public async pushInputToHistory(this: ShellRuntime, value: string) { var hash = window.location.hash; - const encode = btoa(value); + const encode = encodeURIComponent(extraswaps(value)); if (hash === "") hash = "queries=v0"; hash += ","; @@ -77,6 +77,24 @@ function formatBytes(value: number): string { return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? 's' : ''}`}`; } +function extraswaps(input: string): string { + // As long as this function is symmetrical, all good + let res : string = ""; + for (let i=0; i = []; for (var i=1; i< splits.length; i++) { - sqls.push( atob(splits[i])); + sqls.push(extraswaps(decodeURIComponent(splits[i]))); } window.location.hash=""; await step('Rewinding history!', async () => {