From 2f6953857637dfb779c052822a5408aac6e1e400 Mon Sep 17 00:00:00 2001 From: Sjon Hortensius Date: Mon, 3 Oct 2016 16:12:14 +0200 Subject: [PATCH] Fix base64 padding with multiple =-signs. An equal amount of dots is required in output instead of merging all =-signs into one dot, which can then not be decoded. Test string: SELECT * from version where "isHelper" order by "order" desc will be encode to U0VMRUNUICogZnJvbSB2ZXJzaW9uICB3aGVyZSAiaXNIZWxwZXIiIG9yZGVyIGJ5ICJvcmRlciIgZGVzYw. missing a dot at the end making it undecodable. Since =-signs only appear at the end anyway, we don't need the explicit '$' in the regexp --- static/js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 0b36817..ee2647e 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -96,7 +96,7 @@ function explainQuery(query, cb) { apiCall("post", "/explain", { quer function disconnect(cb) { apiCall("post", "/disconnect", {}, cb); } function encodeQuery(query) { - return window.btoa(query).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "."); + return window.btoa(query).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "."); } function buildSchemaSection(name, objects) {