From 4378db612b7354599ec5923e547aab91398ec0e9 Mon Sep 17 00:00:00 2001 From: kim yongbin Date: Wed, 25 Mar 2020 01:03:39 +0900 Subject: [PATCH] UI: decode unicode properly in log page --- ui/app/utils/stream-frames.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/app/utils/stream-frames.js b/ui/app/utils/stream-frames.js index bd4253406..71ceadb41 100644 --- a/ui/app/utils/stream-frames.js +++ b/ui/app/utils/stream-frames.js @@ -15,7 +15,7 @@ export function decode(chunk) { const frames = lines.map(line => JSON.parse(line)).filter(frame => frame.Data); if (frames.length) { - frames.forEach(frame => (frame.Data = window.atob(frame.Data))); + frames.forEach(frame => (frame.Data = b64DecodeUnicode(frame.Data))); return { offset: frames[frames.length - 1].Offset, message: frames.mapBy('Data').join(''), @@ -24,3 +24,10 @@ export function decode(chunk) { return {}; } + +function b64DecodeUnicode(str) { + // from bytestream, to percent-encoding, to original string. + return decodeURIComponent(window.atob(str).split('').map(function(c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); +}